AngelCode.com > Developer resources

Run-time link to the DirectX libraries

Load the DirectX library dynamically instead of linking statically. This will allow you to verify that the library is available and take appropriate actions if it is not. If the library is not available and you linked statically you will not get a chance to deal with it, Windows will automatically shut down the application with a simple message box. The message box will show something like this "DLL xxx.dll missing", which is not very helpful to non-developers. By loading dynamically you will have the chance to give the user a more descriptive message, or even switch to an alternative method, such as a software library.

Don't worry about complicating your development, the only thing you need to change is to add three calls to the following functions.

LoadLibrary()
GetProcAddress()
FreeLibrary()

The DirectX Library uses factory functions, e.g. CreateDirect3D8(), to create and initialize the objects. Once you have the pointer to the object you want to use the rest of the program will be exactly the same.

- Andreas Jönsson