This beginning, I began to explain the whole process of my interface development, step-by-step explanation of the development of the interface process, this article is mainly about hook programming, hook all the forms.
Hook, for most programmers, the word is not unfamiliar. For Windows systems, message messages are passed through the entire system, which is simply an integer and has a corresponding meaning. In C + + Winuser.h, we can see a lot of the message we use. Hook and message is inseparable, it is the Chinese interpretation is "hook", is the monitoring system message transmission, that is, in messages passed to the final word processing, the specific information processing.
For hooks, the main 3 API functions are in the User32.dll file, and these three functions are:
Hook
1///<summary>
2///SetWindowsHookEx
3///</summary>
4 <param name= "Idhook" ></param>
5///<param name= "LPFN" ></PARAM>
6 <param name= "Hmod" ></param>
7///<param name= "dwThreadID" ></PARAM>
8 <returns></returns>
9 [DllImport ("User32.dll", CharSet = CharSet.Auto)]
Pub Lic static extern IntPtr SetWindowsHookEx (int idhook, hookproc lpfn, int hmod, int dwthreadid);
One
///<summary>
///callnexthookex
///</summary>
15 <param name= "HHK" ></PARAM>
///<param name= "ncode" ></PARAM>
17 <param name= "WParam" ></PARAM>
///<param name= "LParam" ></PARAM>
19 <returns></returns>,
20 [DllImport ("User32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr CallNextHookEx Tptr hhk, int ncode, IntPtr wParam, IntPtr lParam);
///<summary>
///unhookwindowshookex
///</summary>
///<param name= "hhk" ></PARAM>
///<returns></returns>
28 [DllImport ("User32.dll", CharSet = CharSet.Auto)]
public static extern bool UnhookWindowsHookEx (IntPtr hhk);
The three methods are to add hooks, release hooks, and execute the next hook. The parameters of which do not need to introduce, the Internet has a lot of information on this.