UnhookWindowsHookEx function (winuser.h)

Removes a hook procedure installed in a hook chain by the SetWindowsHookEx function.

Syntax

BOOL UnhookWindowsHookEx(
  [in] HHOOK hhk
);

Parameters

[in] hhk

Type: HHOOK

A handle to the hook to be removed. This parameter is a hook handle obtained by a previous call to SetWindowsHookEx.

Return value

Type: BOOL

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The hook procedure can be in the state of being called by another thread even after UnhookWindowsHookEx returns. If the hook procedure is not being called concurrently, the hook procedure is removed immediately before UnhookWindowsHookEx returns.

Examples

For an example, see Monitoring System Events.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll
API set ext-ms-win-ntuser-window-l1-1-0 (introduced in Windows 8)

See also

Conceptual

Hooks

Reference

SetWindowsHookEx