原文地址:http://www.zdexe.com/program/201004/579.html
Each type of hook enables an application to monitor a different aspect of the system's message-handling mechanism.
每種類型的鈎子使應用程序能夠監視系統的消息處理機制的不同方面。
鈎子類型1-2:WH_CALLWNDPROC and WH_CALLWNDPROCRET Hooks
The WH_CALLWNDPROC and WH_CALLWNDPROCRET hooks enable you to monitor messages sent to window procedures. The system calls a WH_CALLWNDPROC hook procedure before passing the message to the receiving window procedure, and calls the WH_CALLWNDPROCRET hook procedure after the window procedure has processed the message.
WH_CALLWNDPROC 和 WH_CALLWNDPROCRET鈎子使你能夠監視發送到window程序的消息。系統在將消息傳遞給正在接收的window程序之前,調用WH_CALLWNDPROC鈎子子程;在window程序處理完消息之后,調用WH_CALLWNDPROCRET鈎子子程。
----------------------------------------------------------------------------------------------------------------------------------------------------
The WH_CALLWNDPROCRET hook passes a pointer to a CWPRETSTRUCT structure to the hook procedure. The structure contains the return value from the window procedure that processed the message, as well as the message parameters associated with the message. Subclassing the window does not work for messages set between processes.
WH_CALLWNDPROCRET鈎子將一個指向CWPRETSTRUCT結構的的指針傳遞給鈎子子程。該結構包含有來自處理該消息的window程序的返回值,以及消息中的參數。子類窗體不能處理進程間的消息集。
----------------------------------------------------------------------------------------------------------------------------------------------------
鈎子類型3:WH_CBT Hook
The system calls a WH_CBT hook procedure before activating, creating, destroying, minimizing, maximizing, moving, or sizing a window; before completing a system command; before removing a mouse or keyboard event from the system message queue; before setting the input focus; or before synchronizing with the system message queue. The value the hook procedure returns determines whether the system allows or prevents one of these operations. The WH_CBT hook is intended primarily for computer-based training (CBT) applications.
在以下事件發生之前,系統會調用WH_CBT 鈎子子程:
1、窗台被激活、創建、銷毀、最小化、最大化、移動或者改變大小;
2、執行完系統命令;
3、從系統消息隊列中移除鼠標或者鍵盤事件;
4、設置輸入焦點;
5、同步系統消息隊列;
鈎子子程的返回值決定了系統是允許了還是阻止了這些操作中的一個。WH_CBT鈎子主要是用在基於計算機的練習(CBT) 程序中。
----------------------------------------------------------------------------------------------------------------------------------------------------
鈎子類型4:WH_DEBUG Hook
The system calls a WH_DEBUG hook procedure before calling hook procedures associated with any other hook in the system. You can use this hook to determine whether to allow the system to call hook procedures associated with other types of hooks.
在調用與系統中任何其他鈎子關聯的鈎子子程之前,系統會調用WH_DEBUG 鈎子子程。使用該鈎子來決定是否允許系統調用與其他類型的鈎子相關聯的鈎子子程。
----------------------------------------------------------------------------------------------------------------------------------------------------
鈎子類型5:WH_FOREGROUNDIDLE Hook
The WH_FOREGROUNDIDLE hook enables you to perform low priority tasks during times when its foreground thread is idle. The system calls a WH_FOREGROUNDIDLE hook procedure when the application's foreground thread is about to become idle.
WH_FOREGROUNDIDLE 鈎子允許當前台線程空閑時,執行低權限的任務。系統在應用程序的前台線程即將空閑時,調用WH_FOREGROUNDIDLE鈎子子程。
----------------------------------------------------------------------------------------------------------------------------------------------------
鈎子類型6:WH_GETMESSAGE Hook
The WH_GETMESSAGE hook enables an application to monitor messages about to be returned by the GetMessage or PeekMessage function. You can use the WH_GETMESSAGE hook to monitor mouse and keyboard input and other messages posted to the message queue.
WH_GETMESSAGE程序允許應用程序監視即將由方法GetMessage 或者PeekMessage返回的消息。可以使用WH_GETMESSAGE鈎子監視鼠標和鍵盤輸入,以及其他傳遞給消息隊列的消息。
