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
-
lpFileName
[in] Specifies the name of the module to be loaded. The name can be an internal library name or a full path.
If this parameter is a fully qualified path, this function cannot load a module from a different drive.
If this parameter specifies a module that is in the system's search path, the system searches for the module.
If this parameter is a null-terminated string, the string can contain “%SystemRoot%” which will be replaced by the path to the system directory.
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 |