We recommend using Visual Studio 2017

FreeLibrary and AfxFreeLibrary


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at FreeLibrary and AfxFreeLibrary.

Processes that explicitly link to a DLL call the FreeLibrary function when the DLL module is no longer needed. This function decrements the module's reference count and, if the reference count is zero, unmaps it from the address space of the process.

In an MFC application, use AfxFreeLibrary instead of FreeLibrary to unload an extension DLL. The interface (function prototype) for AfxFreeLibrary is the same as FreeLibrary.

DLLs in Visual C++