FreeLibraryAndExitThread function (libloaderapi.h)
Decrements the reference count of a loaded dynamic-link library (DLL) by one, then calls ExitThread to terminate the calling thread. The function does not return.
void FreeLibraryAndExitThread( [in] HMODULE hLibModule, [in] DWORD dwExitCode );
Do not call this function with a handle returned by either the GetModuleHandleEx function (with the GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT flag) or the GetModuleHandle function, as they do not maintain a reference count for the module.
The exit code for the calling thread.
The FreeLibraryAndExitThread function allows threads that are executing within a DLL to safely free the DLL in which they are executing and terminate themselves. If they were to call FreeLibrary and ExitThread separately, a race condition would exist. The library could be unloaded before ExitThread is called.
|Minimum supported client||Windows XP [desktop apps | UWP apps]|
|Minimum supported server||Windows Server 2003 [desktop apps | UWP apps]|
|Header||libloaderapi.h (include Windows.h)|