public void RegisterHotkey() { if (HotKeyWindow == null) { HotKeyWindow = new HotKeyNativeWindow(this); } try { if (Key != Keys.None) { HotKeyWindow.RegisterHotkey(); } else { if (HotKeyWindow.Handle != IntPtr.Zero) { HotKeyWindow.DestroyHandle(); } HotKeyWindow = null; } } catch { if (HotKeyWindow.Handle != IntPtr.Zero) { HotKeyWindow.DestroyHandle(); } HotKeyWindow = null; throw; } IsRegistered = true; }
public bool RegisterHotkey() { if (HotKeyWindow == null) { HotKeyWindow = new HotKeyNativeWindow(this); } try { if (Key != Keys.None) { HotKeyWindow.RegisterHotkey(); } else { if (HotKeyWindow.Handle != IntPtr.Zero) { HotKeyWindow.DestroyHandle(); } HotKeyWindow = null; } IsRegistered = true; } catch { if (HotKeyWindow.Handle != IntPtr.Zero) { HotKeyWindow.DestroyHandle(); } HotKeyWindow = null; IsRegistered = false; } return(IsRegistered); }