HHOOK SetWindowsHook(nFilterType, pfnFilterProc) | |||||
int nFilterType; | /* type of hook to install | */ | |||
HOOKPROC pfnFilterProc; | /* filter procedure address | */ |
The SetWindowsHook function is obsolete but has been retained for backward compatibility with Windows versions 3.0 and earlier. New Win32 applications should use the SetWindowsHookEx function.
The SetWindowsHook function installs an application-defined hook procedure into a hook chain.
This function is Unicode or ANSI. This information is needed for hooking so the system knows that the hook procedure is expecting Unicode or ANSI when it receives window messages.
nFilterType
Specifies the type of hook procedure to be installed. It can be any one of the following values:
Value | Meaning |
WH_CALLWNDPROC | ||
Installs a window-procedure filter. For more information, see the description of the CallWndProc callback function. | ||
WH_CBT | ||
Installs a computer-based training (CBT) filter. For more information, see the description of the CBTProc callback function. | ||
WH_DEBUG | ||
Installs a debugging filter. For more information, see the description of the DebugProc callback function. | ||
WH_GETMESSAGE | ||
Installs a message filter. For more information, see the description of the GetMsgProc callback function. | ||
WH_JOURNALPLAYBACK | ||
Installs a journaling playback filter. For more information, see the description of the JournalPlaybackProc callback function. | ||
WH_JOURNALRECORD | ||
Installs a journaling record filter. For more information, see the description of the JournalRecordProc callback function. | ||
WH_KEYBOARD | ||
Installs a keyboard filter. For more information, see the description of the KeyboardProc callback function. | ||
WH_MOUSE | ||
Installs a mouse-message filter. For more information, see the description of the MouseProc callback function. | ||
WH_MSGFILTER | ||
Installs a message filter. For more information, see the description of the MessageProc callback function. | ||
WH_SHELL | ||
Installs a shell-application filter. For more information, see the description of the ShellProc callback function. | ||
WH_SYSMSGFILTER | ||
Installs a system-wide message filter. For more information, see the description of the SysMsgProc callback function. |
pfnFilterProc
Points to the hook procedure to be installed.
The return value is a handle of the installed hook procedure, if the function is successful. Otherwise, it is NULL.
The WH_CALLWNDPROC hook will affect system performance. It is supplied for debugging purposes only. It gets called during SendMessage processing by the sender of the window message.
Hook procedures installed by SetWindowsHook are only called in the context of the thread that installed the procedure.
CallNextHookEx, DefHookProc, MessageBox, PeekMessage, PostMessage, SendMessage, SetWindowsHookEx, UnhookWindowsHook, UnhookWindowsHookEx