private static void EnsureSubscribedToGlobalKeyboardEvents() { if (HookManager.s_KeyboardHookHandle != 0) { return; } HookManager.s_KeyboardDelegate = new HookManager.HookProc(HookManager.KeyboardHookProc); HookManager.s_KeyboardHookHandle = HookManager.SetWindowsHookEx(13, HookManager.s_KeyboardDelegate, Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]), 0); if (HookManager.s_KeyboardHookHandle == 0) { throw new Win32Exception(Marshal.GetLastWin32Error()); } }
private static void ForceUnsunscribeFromGlobalKeyboardEvents() { if (HookManager.s_KeyboardHookHandle == 0) { return; } int num = HookManager.UnhookWindowsHookEx(HookManager.s_KeyboardHookHandle); HookManager.s_KeyboardHookHandle = 0; HookManager.s_KeyboardDelegate = (HookManager.HookProc)null; if (num == 0) { throw new Win32Exception(Marshal.GetLastWin32Error()); } }
private static extern int SetWindowsHookEx( int idHook, HookManager.HookProc lpfn, IntPtr hMod, int dwThreadId);
private static void ForceUnsunscribeFromGlobalMouseEvents() { if (HookManager.s_MouseHookHandle != 0) { int num = HookManager.UnhookWindowsHookEx(HookManager.s_MouseHookHandle); HookManager.s_MouseHookHandle = 0; HookManager.s_MouseDelegate = null; if (num == 0) { int lastWin32Error = Marshal.GetLastWin32Error(); throw new Win32Exception(lastWin32Error); } } }
private static void EnsureSubscribedToGlobalMouseEvents() { if (HookManager.s_MouseHookHandle == 0) { HookManager.s_MouseDelegate = new HookManager.HookProc(HookManager.MouseHookProc); HookManager.s_MouseHookHandle = HookManager.SetWindowsHookEx(14, HookManager.s_MouseDelegate, Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]), 0); if (HookManager.s_MouseHookHandle == 0) { int lastWin32Error = Marshal.GetLastWin32Error(); throw new Win32Exception(lastWin32Error); } } }