FreeLibraryAndExitThread

FreeLibraryAndExitThread decrements the reference count of the loaded dynamic-link library (DLL) by one, then calls ExitThread to terminate the calling thread.

Syntax

Copy
VOID FreeLibraryAndExitThread(
  [in] HMODULE hLibModule,
  [in] DWORD   dwExitCode
);

Parameters

[in] hLibModule

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 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.

[in] dwExitCode

The exit code for the calling thread.

Return Value

None.

Remarks

FreeLibraryAndExitThread 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 version Header Library

wRTOS 1.0 SDK

windows.h

wRTOS_rtss.lib

See Also: