Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

UnhookWinEvent

The UnhookWinEvent function removes an event hook function created by a previous call to SetWinEventHook.

BOOL WINAPI UnhookWinEvent(
  HWINEVENTHOOK hWinEventHook
);

Parameters

hWinEventHook
[in] Handle to the event hook returned in the previous call to SetWinEventHook.

Return Values

If successful, returns TRUE.

If unsuccessful, returns FALSE.

Three common errors cause this function to fail:

  • The hWinEventHook parameter is NULL or invalid.
  • The event hook specified by hWinEventHook was already removed.
  • UnhookWinEvent is called from a thread different from the original call to SetWinEventHook.

Remarks

This function removes the event hook specified by hWinEventHook that prevents the corresponding callback function from receiving further event notifications. If the client's thread ends, the system automatically calls this function.

Call this function from the same thread that installed the event hook. UnhookWinEvent fails if called from a thread different from the call that corresponds to SetWinEventHook.

If WINEVENT_INCONTEXT was specified when this event hook was installed, the system attempts to unload the corresponding DLL from all processes that loaded it. Although unloading does not occur immediately, the hook function is not called after UnhookWinEvent returns. For more information on WINEVENT_INCONTEXT, see In-Context Hook Functions.

Requirements

  Windows NT/2000/XP/Server 2003: Included in Windows 2000 and later.
  Windows 95/98/Me: Included in Windows 98 and later.
  Redistributable: Requires Active Accessibility 1.3 RDK on Windows NT 4.0 SP6 and Windows 95.
  Header: Declared in Winuser.h; include Windows.h.
  Library: Use User32.lib.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.