UnhookWinEvent

[This is preliminary documentation and subject to change.]

Removes an event hook created by a previous call to SetWinEventHook.

BOOL WINAPI UnhookWinEvent(
  HWINEVENTHOOK hWinEventHook
);
 

Parameters

hWinEventHook
Handle to the event hook that was returned in the previous call to SetWinEventHook.

Return Values

Returns TRUE if successful or FALSE otherwise.

Three common errors will cause this function to fail:

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

Remarks

This function removes the event hook specified by hWinEventHook, preventing the accompanying callback function from receiving further notifications. Clients should call this function when event notification is no longer needed or if the client's thread is ending for any reason.

Ensure that you call this function from the same thread that installed the event hook. USER will not allow threads to remove event hooks that they do not own.

If WINEVENT_INCONTEXT is specified when installing this event hook, winable.h will attempt to unload the corresponding DLL from all processes that loaded it. Although unloading might not occur immediately, the callback function will not be called after UnhookWinEvent returns.