//检测硬件改变 protected override void WndProc(ref Message m) { const int WM_DEVICECHANGE = 0x219; if (m.Msg == WM_DEVICECHANGE) { if(UsbDev.FindUsbDev(0x000b, 0x8888)) { //尝试打开USB if (UsbConnect == true) return;//说明是其他设备活动 UsbConnect = UsbDev.OpenDev(0x000b, 0x8888); if (UsbConnect) labelUsb.Text = "USB连接成功"; else labelUsb.Text = "USB连接失败"; } else { labelUsb.Text = "USB连接失败"; UsbConnect = false; } } base.WndProc(ref m); }
时间: 2024-10-08 18:10:40