Loading a DLL implicitly

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 a C++ DLL contains static classes, their constructors are run when the DLL is loaded, typically before the main function runs. Their destructors run once after the main function returns.

To implicitly load a DLL from C or C++, do one of the following:
  • Statically initialize a variable pointer to the address of an exported DLL variable.
  • Reference a function pointer that points to an exported function.
  • Call an exported function.
  • Reference (use, modify, or take the address of) an exported variable.
  • Call through a function pointer that points to an exported function.
To implicitly load a DLL from COBOL, do one of the following:
  • Call a function that is exported from the DLL.
  • Set a COBOL procedure-pointer to a function that is exported from the DLL.
  • Invoke a method that is defined in a class contained in the DLL.

When the first reference to a DLL is from static initialization of a C or C++ variable pointer, the DLL is loaded before the main function is invoked. Any C++ constructors are run before the main function is invoked.