UnhookWindowsHookEx() private method

private UnhookWindowsHookEx ( IntPtr hhk ) : bool
hhk IntPtr
return bool
Beispiel #1
0
 /// <summary>
 /// Detach the keyboard hook; call during shutdown to prevent calls as we unload
 /// </summary>
 private static void DetachKeyboardHook()
 {
     if (_hookID != IntPtr.Zero)
     {
         InterceptKeys.UnhookWindowsHookEx(_hookID);
     }
 }
Beispiel #2
0
 public static void Run()
 {
     InterceptKeys.callback = new InterceptKeys.CallBack(MySelector);
     InterceptKeys._hookID  = InterceptKeys.SetHook(InterceptKeys._proc);
     Application.Run();
     InterceptKeys.UnhookWindowsHookEx(InterceptKeys._hookID);
 }
Beispiel #3
0
 private void F_accueil_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (to_be_saved == true && Is_Closing == false)
     {
         MessageBoxButtons buttons = MessageBoxButtons.YesNoCancel;
         DialogResult      result  = MessageBox.Show("Voulez-vous sauvegarder la proposition sous excel ?", "", buttons);
         if (result == DialogResult.Yes)
         {
             closing    = e;
             Is_Closing = true;
         }
         else if (result == DialogResult.No)
         {
             //Program.Connection_COQUE.close_COQUE();
             InterceptKeys.UnhookWindowsHookEx(InterceptKeys.Key_hookID);
             InterceptKeys.UnhookWindowsHookEx(InterceptKeys.Click_hookID);
             //fEnvoiMail();
             to_be_saved = false;
             Application.Exit();
         }
         else if (result == DialogResult.Cancel)
         {
             e.Cancel = true;
         }
     }
     else
     {
         InterceptKeys.UnhookWindowsHookEx(InterceptKeys.Key_hookID);
         InterceptKeys.UnhookWindowsHookEx(InterceptKeys.Click_hookID);
         //fEnvoiMail();
         Application.Exit();
     }
 }
 public void Dispose()
 {
     InterceptKeys.UnhookWindowsHookEx(hookId);
 }
        static KeyboardHook()
        {
            IntPtr hookId = InterceptKeys.SetHook(_handler);

            AppDomain.CurrentDomain.ProcessExit += (s, e) => InterceptKeys.UnhookWindowsHookEx(hookId);
        }