private void SafeRemove() { if (this.handle != IntPtr.Zero) { NativeExports.UnhookWindowsHookEx(this.handle); this.OnSuccessfullUnhook(); } }
public void RemoveHook() { if (this.State == HookState.Installed) { if (NativeExports.UnhookWindowsHookEx(this.handle)) { this.OnSuccessfullUnhook(); } else { var errorCode = NativeExports.GetLastError(); throw new Exception(ErrorCodeHelper.GetMessage(errorCode)); } } }