Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

FreeLibraryAndExitThread function

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.

Syntax


VOID WINAPI FreeLibraryAndExitThread(
  _In_ HMODULE hModule,
  _In_ DWORD   dwExitCode
);

Parameters

hModule [in]

A handle to the DLL module whose reference count the function decrements. The LoadLibrary or GetModuleHandleEx function returns this handle.

Do not call this function with a handle returned by the GetModuleHandle function, since this function does not maintain a reference count for the module.

dwExitCode [in]

The exit code for the calling thread.

Return value

This function does not return a value. Invalid module handles are ignored.

Remarks

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.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Winbase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

See also

DisableThreadLibraryCalls
Dynamic-Link Library Functions
ExitThread
FreeLibrary
Run-Time Dynamic Linking

 

 

Community Additions

ADD
Show:
© 2015 Microsoft