FreeLibrary

2.x

  void FreeLibrary(hinst)    
  HINSTANCE hinst; /* handle of loaded library module */

The FreeLibrary function decrements (decreases by one) the reference count of the loaded library module. When the reference count reaches zero, the memory occupied by the module is freed.

Parameters

hinst

Identifies the loaded library module.

Return Value

This function does not return a value.

Comments

A dynamic-link library (DLL) must not call the FreeLibrary function within its WEP function (Windows exit procedure).

The reference count for a library module is incremented (increased by one) each time an application calls the LoadLibrary function for the library module.

Example

The following example uses the LoadLibrary function to load TOOLHELP.DLL and the FreeLibrary function to free it:

HINSTANCE hinstToolHelp = LoadLibrary("TOOLHELP.DLL");

if ((UINT) hinstToolHelp > 32) {
        .
        . /* use GetProcAddress to use TOOLHELP functions */
        .
}
else {
    ErrorHandler();
}

if ((UINT) hinstToolHelp > 32)
   FreeLibrary(hinstToolHelp); /* free TOOLHELP.DLL      */

See Also

GetProcAddress, LoadLibrary, WEP