Why LoadLibraryEx() Returns an HINSTANCE

ID: Q102128

3.50 3.51 4.00 WINDOWS NT kbprg

The information in this article applies to:

In the Win32 Help files, LoadLibrary() is typed to return a HANDLE, while LoadLibraryEx() is prototyped to return a HINSTANCE.

An HINSTANCE return from LoadLibraryEx() is useful because processes that load dynamic-link libraries (DLLs) do not necessarily want the overhead of having to page in code for a DllEntryPoint routine when the DLL does not need to initialize information. This is especially useful when you have multiple threads that attach to already loaded DLLs. In this case, you may want to not implicitly load via LoadLibrary() and instead use LoadLibraryEx() to explicitly load without having to page in the code for every attach.

LoadLibraryEx() is also useful if you want to retrieve resources from a DLL or an EXE. In this case, you would use LoadLibraryEx() to load the module you want into your address space, without executing DLLEntryPoint, and then use the resource application programming interfaces (APIs) to access the data.

KBCategory: kbprg KBSubcategory: BseDll Additional reference words: 3.50 3.51 4.00

Keywords          : kbDLL kbKernBase kbGrpKernBase 
Version           : 3.50 3.51 4.00
Platform          : NT WINDOWS

Last Reviewed: December 19, 1996