public static extern bool UnhookWindowsHook(HookHandle hook);
 public static extern IntPtr CallNextHook(HookHandle hook, int code, IntPtr wParam, IntPtr lParam);
Exemplo n.º 3
0
        public void Uninstall()
        {
            lock (this)
            {

                if (!this.HookHandle.IsEmpty)
                {
                    while (true)
                    {

                        if (!UnsafeNativeMethods.UnhookWindowsHook(this.HookHandle))
                        {
                            throw new Win32Exception(Marshal.GetLastWin32Error());
                        }

                        _Handle = HookHandle.Empty;
                        this._HookProc = null;

                        return;
                    }
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Equalses the specified hook.
 /// </summary>
 /// <param name="hook">The hook.</param>
 /// <returns></returns>
 public bool Equals(HookHandle hook)
 {
     if (this._Hook.Equals(hook._Hook))
     {
         return true;
     }
     return false;
 }
Exemplo n.º 5
0
        public void Install()
        {
            if (!this.HookHandle.IsEmpty)
            {
                this.Uninstall();
            }
            while (true)
            {
                lock (this)
                {
                    this._Handle = UnsafeNativeMethods.SetWindowsHook(this.HookType, this._HookProc,
                     InstanceHandle.Empty, (uint)Window.ThreadID);
                    if (this.HookHandle.IsEmpty)
                    {
                        throw new Win32Exception(Marshal.GetLastWin32Error());
                    }

                    return;
                }
            }
        }