public void Unregister() { // Check that we have registered if (!this.IsRegistered) { return; } this.IsRegistered = false; Application.RemoveMessageFilter(this); // Clean up after ourselves HotkeyHandlerNativeMethods.UnregisterHotKey(this._hotkeyTarget, this._hotkeyId); }
public void Unregister() { // Check that we have registered if (!this.IsRegistered) { throw new NotSupportedException("This hotkey was not registered"); } Application.RemoveMessageFilter(this); // Clean up after ourselves if (!HotkeyHandlerNativeMethods.UnregisterHotKey(this._hotkeyTarget, this._hotkeyId)) { throw new Win32Exception(); } this.IsRegistered = false; }