private static extern int CallNextHookEx( HookKeyProc hhk, int nCode, IntPtr wParam, IntPtr lParam );
//安装钩子 public void Start() { if (hHookKey != 0) { //Unhook the previouse one this.Stop(); } hookKeyDeleg = new HookKeyProc(HookKeyProcedure); hHookKey = SetWindowsHookEx(WH_KEYBOARD_LL, hookKeyDeleg, GetModuleHandle(null), 0); if (hHookKey == 0) { SecurityHelp.WriteLog(this.clsName + " Failed acquiring of the hook."); throw new SystemException("Failed acquiring of the hook."); } }
private static extern int SetWindowsHookEx(int type, HookKeyProc HookKeyProc, IntPtr hInstance, int m);
private void Start() { if (this.hHookKey != 0) { this.Stop(); } this.hookKeyDeleg = new HookKeyProc(this.HookKeyProcedure); this.hHookKey = SetWindowsHookEx(20, this.hookKeyDeleg, GetModuleHandle(null), 0); if (this.hHookKey == 0) { } }
private static extern int CallNextHookEx(HookKeyProc hhk, int nCode, IntPtr wParam, IntPtr lParam);