Exemple #1
0
 /// <summary>
 /// 安装钩子
 /// </summary>
 public void InstallHook()
 {
     if (khook == IntPtr.Zero)
     {
         uint id = Win32Helper.GetCurrentThreadId();
         this.KeyboardProcDelegate = new Win32Helper.HookProc(this.KeyboardProc);
         khook = Win32Helper.SetWindowsHookEx((IntPtr)HookHelper.WH_Codes.WH_KEYBOARD_LL, this.KeyboardProcDelegate, IntPtr.Zero, id);
     }
 }
Exemple #2
0
 /// <summary>
 /// 安装鼠标钩子
 /// </summary>
 public void InstallHook()
 {
     if (hHook == IntPtr.Zero)
     {
         uint id = Win32Helper.GetCurrentThreadId();
         this.MouseHookProcedure = new Win32Helper.HookProc(this.MouseHookProc);
         //这里挂节钩子
         hHook = Win32Helper.SetWindowsHookEx((IntPtr)HookHelper.WH_Codes.WH_MOUSE_LL, MouseHookProcedure, IntPtr.Zero, id);
     }
 }