Platform SDK: DLLs, Processes, and Threads

FreeLibraryAndExitThread

The FreeLibraryAndExitThread function decrements the reference count of a loaded dynamic-link library (DLL) by one, and then calls ExitThread to terminate the calling thread. The function does not return.

The FreeLibraryAndExitThread function gives threads that are created and executed within a dynamic-link library an opportunity to safely unload the DLL and terminate themselves.

VOID FreeLibraryAndExitThread(
  HMODULE hModule,  // handle to the DLL module
  DWORD dwExitCode  // exit code for thread
);

Parameters

hModule
[in] Handle to the DLL module whose reference count the function decrements. The LoadLibrary or GetModuleHandle function returns this handle.
dwExitCode
[in] Specifies the exit code for the calling thread.

Return Values

The function has no return value. The function does not return. Invalid hModule handles are ignored.

Remarks

The FreeLibraryAndExitThread function is implemented as:

FreeLibrary(hModule); 
ExitThread(dwExitCode); 

Refer to the reference pages for FreeLibrary and ExitThread for further information on those functions.

Requirements

  Windows NT/2000: Requires Windows NT 3.5 or later.
  Windows 95/98: Requires Windows 95 or later.
  Header: Declared in Winbase.h; include Windows.h.
  Library: Use Kernel32.lib.

See Also

Dynamic-Link Libraries Overview, Dynamic-Link Library Functions, FreeLibrary, ExitThread, DisableThreadLibraryCalls