protected override void WndProc(ref Message m) { if (m.Msg == Win32.WM_DEVICECHANGE) { if (m.WParam.ToInt32() == Win32.DBT_DEVICEARRIVAL) { OpenHIDDevice(); } else if (m.WParam.ToInt32() == Win32.DBT_DEVICEREMOVECOMPLETE) { if (HID.DeviceNameMatch(m, hidDevice.pathName)) { CloseHIDDevice(); } } UpdateUI(); } base.WndProc(ref m); }