## INFO: Why LoadLibraryEx() Returns an HINSTANCE

Q102128

The information in this article applies to:

- Microsoft Win32 Application Programming Interface (API), used with:
  - the operating system: Microsoft Windows NT, versions 3.5, 3.51, 4.0
  - the operating system: Microsoft Windows 2000

## SUMMARY

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.

Additional query words: 3.50

Keywords : kbDLL kbKernBase kbOSWin2000 kbDSupport kbGrpDSKernBase
Issue type : kbinfo
Technology : kbAudDeveloper kbWin32sSearch kbWin32API

Last Reviewed: October 27, 2000 © 2001 Microsoft Corporation. All rights reserved. Terms of Use.