LoadLibraryA Function

Library Management Functions

LoadLibraryA Function

The LoadLibraryA function (using the ANSI character set) loads the specified module into the address space of the calling process and returns a handle to the module.

Syntax


BOOL WINAPI LoadLibraryA(
  LPCSTR lpFileName
);
            

Parameters

Return Value

If the function succeeds, the return value is a handle to the module. A handle is a 32-bit value that can be used to identify the module in subsequent calls to other functions in the system.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Remarks

The LoadLibraryA function maps the specified executable module into the address space of the calling process.

If the module has not been loaded yet, a handle to it is returned.

If the module has already been loaded by another process, a handle to the existing module is returned and the reference count for the module is incremented.

The system maintains a list of modules that have been loaded into an address space. When a module is loaded, the system checks this list to see if the module has already been loaded. If it has, the system returns the handle to the module and increments the module's reference count. If the module has not been loaded, the system loads it, adds it to the list, and returns a handle to the module.

A calling application can call FreeLibrary to decrement the reference count of a loaded module.

When calling LoadLibraryA, consider the following:

  • The calling process must have sufficient memory to map the module.
  • The calling process must have the necessary permissions to access the module.

Requirements

Product Minimum supported client Minimum supported server
This API is supported on the following Windows operating systems: Windows XP (with Service Pack 2) Windows Server 2003 (with Service Pack 1)
Header Winbase.h Winbase.h
Library Kernel32.lib Kernel32.lib
DLL Kernel32.dll Kernel32.dll

See Also