Name

SetWindowsHookEx

Synopsis

Installs the specified window’s hook:

Public Declare Function SetWindowsHookEx Lib "user32" _
		Alias "SetWindowsHookExA" _
		(ByVal idHook As Long, ByVal lpfn As Long, _
		ByVal hmod As Long, ByVal dwThreadId As Long) As Long

Parameters

idHook

This is the identifier of the type of hook that is being installed.

lpfn

Function pointer that points to the hook callback function.

hmod

The handle of the DLL containing the hook callback function. If this is NULL, the hook callback function is not contained within a DLL. Instead, it is contained in the application’s (EXE’s) code.

dwThreadId

The application’s thread that contains the hook callback function. If this is NULL, the hook callback function is contained within a DLL (see hmod).

Return Value

Returns the handle to the newly created hook. A return value of zero indicates failure.

Get Subclassing and Hooking with Visual Basic now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.