When an application uses functions or variables defined in a DLL, the compiled code loads the DLL. This implicit load is transparent to the application. The load establishes the required references to functions and variables in the DLL by updating the control information contained in function and variable descriptors.
If the DLL contains static classes, constructors are run when the DLL is loaded. This loading may occur before main(); in this case, the corresponding destructors are run once when main() returns.
To implicitly load a DLL, do one of the following:
In the first situation, the DLL is loaded before main() is invoked, and if the DLL contains C++ code, constructors are run before main() is invoked. In the other situations, the DLL loading may be delayed until the time of the implicit call, although optimization may move this load earlier.
If the DLL application references (imports) an exported DLL variable, that DLL may be implicitly loaded before that DLL application is invoked (not necessarily before main() is invoked). With XPLINK, the DLL will always be implicitly loaded before invoking the DLL application that references (imports) a DLL variable or takes the address of a DLL function.