You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- // This code is distributed under MIT license.
- // Copyright (c) 2015 George Mamaladze
- // See license.txt or https://mit-license.org/
-
- using System.Windows.Forms;
- using Microsoft.Win32.SafeHandles;
-
- namespace Gma.System.MouseKeyHook.WinApi
- {
- internal class HookProcedureHandle : SafeHandleZeroOrMinusOneIsInvalid
- {
- private static bool _closing;
-
- static HookProcedureHandle()
- {
- Application.ApplicationExit += (sender, e) => { _closing = true; };
- }
-
- public HookProcedureHandle()
- : base(true)
- {
- }
-
- protected override bool ReleaseHandle()
- {
- //NOTE Calling Unhook during processexit causes deley
- if (_closing) return true;
- return HookNativeMethods.UnhookWindowsHookEx(handle) != 0;
- }
- }
- }
|