public bool Unregister() { // Check that we have registered if (!this.registered) { throw new NotSupportedException("You cannot unregister a hotkey that is not registered"); } // Clean up after ourselves bool result = (Hotkey.UnregisterHotKey(this.windowControl.Handle, this.id) != 0); // Clear the control reference and register state this.registered = false; this.windowControl = null; return(result); }
public void Unregister() { // Check that we have registered if (!this.registered) { throw new NotSupportedException("You cannot unregister a hotkey that is not registered"); } // It's possible that the control itself has died: in that case, no need to unregister! if (!this.windowControl.IsDisposed) { // Clean up after ourselves if (Hotkey.UnregisterHotKey(this.windowControl.Handle, this.id) == 0) { throw new Win32Exception(); } } // Clear the control reference and register state this.registered = false; this.windowControl = null; }