/// <summary> /// Install low level keyboard hook /// </summary> public void Install() { hookHandler = HookFunc; hookID = SetHook(hookHandler); }
/// <summary> /// Registers hook with Windows API /// </summary> /// <param name="proc">Callback function</param> /// <returns>Hook ID</returns> private IntPtr SetHook(KeyCatchInfoHandler proc) { using (ProcessModule module = Process.GetCurrentProcess().MainModule) return(SetWindowsHookEx(13, proc, GetModuleHandle(module.ModuleName), 0)); }
private static extern IntPtr SetWindowsHookEx(int idHook, KeyCatchInfoHandler lpfn, IntPtr hMod, uint dwThreadId);