BOOL FreeLibrary(hLibModule) | |||||
HANDLE hLibModule; | /* identifies loaded library module | */ |
The FreeLibrary function decreases the reference count of the loaded library module by one. When the reference count reaches zero, the module is unmapped from the address space of the process and the handle is no longer valid.
hLibModule
Identifies the loaded library module. The LoadLibrary function returns this handle.
The return value is TRUE if the function was successful, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.
Each process maintains a reference count for each loaded library module. This reference count is incremented each time LoadLibrary is called. A library module that is loaded at process initialization due to load-time dynamic linking has a reference count of one, which could be incremented if the same module is loaded by a call to LoadLibrary.
When the reference count for the specified library module is decremented to zero, the DLL's LibMain function is called with the DLL_PROCESS_DETACH code. This allows the library module to clean up resources that were allocated on behalf of the current process. Finally, after LibMain returns, the library module is removed from the address space of the current process.
Calling FreeLibrary does not affect other processes that are using the same library module.