コード例 #1
0
 private IntPtr MyHookProc(int code, IntPtr wparam, ref KeyboardMsg lParam)
 {
     if (lParam.vkCode == (int)Keys.LWin || lParam.vkCode == (int)Keys.RWin)
     {
         return((IntPtr)1);
     }
     if ((int)System.Windows.Forms.Control.ModifierKeys == (int)Keys.LWin || (int)System.Windows.Forms.Control.ModifierKeys == (int)Keys.RWin)
     {
         return((IntPtr)1);
     }
     if (lParam.vkCode == (int)Keys.F4 && (int)System.Windows.Forms.Control.ModifierKeys == (int)Keys.Alt)
     {
         return((IntPtr)1);
     }
     return(CallNextHookEx(_nextHookPtr, code, wparam, ref lParam));
 }
コード例 #2
0
 private IntPtr MyHookProc(int code, IntPtr wparam, ref KeyboardMsg lParam)
 {
     if (code >= 0 && (wparam == (IntPtr)WM_KEYDOWN || wparam == (IntPtr)WM_SYSKEYDOWN))
     {
         //返回一个伪值以截取键击。
         int num = 0;
         if (int.TryParse(Convert.ToChar(lParam.vkCode).ToString(), out num))
         {
             BarCode += num.ToString();
         }
         else
         {
             return((IntPtr)1);
         }
     }
     return(CallNextHookEx(_nextHookPtr, code, wparam, ref lParam));
 }
コード例 #3
0
 private extern static IntPtr CallNextHookEx(IntPtr handle, int code, IntPtr wparam, ref KeyboardMsg lParam); //取得下一个Hook的API