public static extern IntPtr SetWindowsHookEx( int idHook, HookDefault lpfn, IntPtr hMod, uint dwThreadId);
/// <summary> /// Creates windows hook /// </summary> /// <param name="hookHndlr">Function for handling hooked events</param> public static void CreateHook(HookHandler hookHndlr) { Process _this = Process.GetCurrentProcess(); ProcessModule mod = _this.MainModule; hookDefault = HookFunc; hookHandler = hookHndlr; currentHook = NativeMethods.SetWindowsHookEx(13, hookDefault, NativeMethods.GetModuleHandle(mod.ModuleName), 0); }