Loading Resources From a DLL

Presentation Manager resources may also be defined and stored in a dynamic link library. The process of compiling and placing resources in a DLL is described in Presentation Manager Resources in a DLL. Once a resource is located in a DLL however, the DLL module must be loaded into memory by the application, and a module handle obtained at run time before the resource may be accessed by a Presentation Manager function. This is typically achieved using the DosLoadModule() or DosGetModuleHandle() functions. Figure "Loading Resources From a DLL" illustrates the necessary code to load a dynamic link library named MYDLL from a directory identified in the LIBPATH statement in CONFIG.SYS, and to load a string resource from this DLL.

The DosLoadModule() function call loads the dynamic link library with the name "MYDLL" (the default extension of .DLL is assumed) into memory and returns a handle hModule of type HMODULE. This handle is then passed as the resource file identifier to the WinLoadString() function call, which accesses the resources within the module. Other function calls such as WinLoadPointer() work in a similar manner.


[Back: Loading From Within the Application]
[Next: Loading Dialogs From a DLL]