------------------------------------------------设置钩子-------------------------------------------------------------------
SetWindowsHookEx(
idHook: Integer; {钩子类型}
lpfn: TFNHookProc; {函数指针}
hmod: HINST; {包含钩子函数的模块(EXE、DLL)句柄; 一般是 HInstance; 如果是当前线程这里可以是 0}
dwThreadId: DWORD {关联的线程; 可用 GetCurrentThreadId 获取当前线程; 0 表示是系统级钩子}
): HHOOK; {返回钩子的句柄; 0 表示失败}
//钩子类型 idHook 选项:
WH_MSGFILTER = -1; {线程级; 截获用户与控件交互的消息}
WH_JOURNALRECORD = 0; {系统级; 记录所有消息队列从消息队列送出的输入消息, 在消息从队列中清除时发生; 可用于宏记录}
WH_JOURNALPLAYBACK = 1; {系统级; 回放由 WH_JOURNALRECORD 记录的消息, 也就是将这些消息重新送入消息队列}
WH_KEYBOARD = 2; {系统级或线程级; 截获键盘消息}
WH_GETMESSAGE = 3; {系统级或线程级; 截获从消息队列送出的消息}
WH_CALLWNDPROC = 4; {系统级或线程级; 截获发送到目标窗口的消息, 在 SendMessage 调用时发生}
WH_CBT = 5; {系统级或线程级; 截获系统基本消息, 譬如: 窗口的创建、激活、关闭、最大最小化、移动等等}
WH_SYSMSGFILTER = 6; {系统级; 截获系统范围内用户与控件交互的消息}
WH_MOUSE = 7; {系统级或线程级; 截获鼠标消息}
WH_HARDWARE = 8; {系统级或线程级; 截获非标准硬件(非鼠标、键盘)的消息}
WH_DEBUG = 9; {系统级或线程级; 在其他钩子调用前调用, 用于调试钩子}
WH_SHELL = 10; {系统级或线程级; 截获发向外壳应用程序的消息}
WH_FOREGROUNDIDLE = 11; {系统级或线程级; 在程序前台线程空闲时调用}
WH_CALLWNDPROCRET = 12; {系统级或线程级; 截获目标窗口处理完毕的消息, 在 SendMessage 调用后发生}
------------------------------------------卸载钩子--------------------------------------------------------------
UnhookWindowsHookEx(
hhk: HHOOK {钩子句柄}
): BOOL; {True/False}
-------------------------------------调用下一个钩子----------------------------------------------------------------
CallNextHookEx(
hhk: HHOOK; {当前钩子的句柄}
nCode: Integer; {钩子代码; 就是给下一个钩子要交待的}
wParam: WPARAM; {要传递的参数; 由钩子类型决定是什么参数}
lParam: LPARAM {要传递的参数; 由钩子类型决定是什么参数}
): LRESULT; {会返回下一个钩子执行后的返回值; 0 表示失败}
//参数 nCode 的可选值:
HC_ACTION = 0; {}
HC_GETNEXT = 1; {}
HC_SKIP = 2; {}
HC_NOREMOVE = 3; {}
HC_NOREM = HC_NOREMOVE; {}
HC_SYSMODALON = 4; {}
HC_SYSMODALOFF = 5; {}
-------------------------------------钩子回调函数-----------------------------------------------------------
MsgFilterProc(
nCode: Integer; {}
wParam: WPARAM; {}
lParam: LPARAM {}
): LRESULT; {}
-----------------------------------------------------钩子回调函数-------------------------------------------------------------
JournalRecordProc(
nCode: Integer; {}
wParam: WPARAM; {}
lParam: LPARAM {}
): LRESULT; {}
--------------------------------------------------钩子回调函数------------------------------------------------------------
KeyboardProc(
nCode: Integer; {}
wParam: WPARAM; {}
lParam: LPARAM {}
): LRESULT; {}
------------------------------------------钩子回调函数------------------------------------------------------------
JournalPlaybackProc(
nCode: Integer; {}
wParam: WPARAM; {}
lParam: LPARAM {}
): LRESULT; {}
--------------------------------------钩子回调函数------------------------------------------------------------
GetMsgProc(
nCode: Integer; {}
wParam: WPARAM; {}
lParam: LPARAM {}
): LRESULT; {}
--------------------------------------------------钩子回调函数------------------------------------------------------------
CallWndProc(
nCode: Integer; {}
wParam: WPARAM; {}
lParam: LPARAM {}
): LRESULT; {}
---------------------------------------------------钩子回调函数------------------------------------------------------------
该函数在
窗口被激活、创建、销毁、最大化、最小化、移动、改变大小等动作前;
完成一条系统命令前;
从系统消息队列中移去一个鼠标或键盘消息前;
与系统消息同步前;
被调用!
CBTProc(
nCode: Integer; {要处理的消息类型, 见下表}
wParam: WPARAM; {消息对应的参数, 见下表}
lParam: LPARAM {消息对应的参数, 见下表}
): LRESULT; {返回值表示是否阻止某个事件的发生}
---------------------------------------------------------------------------------------------------
MouseProc(
nCode: Integer; {}
wParam: WPARAM; {}
lParam: LPARAM {}
): LRESULT; {}
---------------------------------------------------------------------------------------------------------
HardwareProc(
nCode: Integer; {}
wParam: WPARAM; {}
lParam: LPARAM {}
): LRESULT; {}
-------------------------------------------------------------------------------------------------------------
DebugProc(
nCode: Integer; {}
wParam: WPARAM; {}
lParam: LPARAM {}
): LRESULT; {}
------------------------------------------------------------------------------------------------------------、
ShellProc(
nCode: Integer; {}
wParam: WPARAM; {}
lParam: LPARAM {}
): LRESULT; {}
------------------------------------------------------------------------------------------------------------
ForegroundIdleProc(
nCode: Integer; {}
wParam: WPARAM; {}
lParam: LPARAM {}
): LRESULT; {}
----------------------------------------------------------------------------------------------------------------
CallWndProcRetProc(
nCode: Integer; {}
wParam: WPARAM; {}
lParam: LPARAM {}
): LRESULT; {}