Beispiel #1
0
 public void Attach()
 {
     _hookProc   = new Win32Helper.HookProc(this.HookProc);
     _windowHook = Win32Helper.SetWindowsHookEx(
         Win32Helper.HookType.WH_CBT,
         _hookProc,
         IntPtr.Zero,
         (int)Win32Helper.GetCurrentThreadId());
 }
 public void Attach()
 {
     _hookProc = HookProc;
     _windowHook = Win32Helper.SetWindowsHookEx(
         Win32Helper.HookType.WhCbt,
         _hookProc,
         IntPtr.Zero,
         (int) Win32Helper.GetCurrentThreadId());
 }
 public void Attach()
 {
     _hookProc = new Win32Helper.HookProc(this.HookProc);
     _windowHook = Win32Helper.SetWindowsHookEx(
         Win32Helper.HookType.WH_CBT,
         _hookProc,
         IntPtr.Zero,
         (int)Win32Helper.GetCurrentThreadId());
 }
 public void Attach()
 {
     _hookProc   = HookProc;
     _windowHook = Win32Helper.SetWindowsHookEx(
         Win32Helper.HookType.WhCbt,
         _hookProc,
         IntPtr.Zero,
         (int)Win32Helper.GetCurrentThreadId());
 }
Beispiel #5
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);
     }
 }
Beispiel #6
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);
     }
 }
Beispiel #7
0
        /// <summary>
        ///     安装键盘钩子
        /// </summary>
        public void SetHook()
        {
            _keyboardHookDelegate = KeyboardHookProc;
            var cModule = Process.GetCurrentProcess().MainModule;

            if (null == cModule)
            {
                return;
            }
            var moduleHandle = Win32Helper.GetModuleHandle(cModule.ModuleName);

            _hKeyboardHook =
                Win32Helper.SetWindowsHookEx(Win32Helper.WH_KEYBOARD_LL, _keyboardHookDelegate, moduleHandle, 0);
        }
Beispiel #8
0
 public static extern IntPtr SetWindowsHookEx(Win32Helper.HookType code, Win32Helper.HookProc func, IntPtr hInstance, int threadID);