这是采用C#开发的一个USB库,使您可以管理USB设备的连接和分离事件,探测自己的设备。可以运行在Windows XP和Windows7 64位系统下。
01 | private void USBPort_USBDeviceAttached( object sender, |
02 | USBClass.USBDeviceEventArgs e) |
04 | if (!MyUSBDeviceConnected) |
06 | if (USBClass.GetUSBDevice(MyDeviceVID, MyDevicePID, |
07 | ref USBDeviceProperties, false )) |
09 | //My Device is connected |
10 | MyUSBDeviceConnected = true ; |
15 | private void USBPort_USBDeviceRemoved( object sender, |
16 | USBClass.USBDeviceEventArgs e) |
18 | if (!USBClass.GetUSBDevice(MyDeviceVID, MyDevicePID, |
19 | ref USBDeviceProperties, false )) |
21 | //My Device is removed |
22 | MyUSBDeviceConnected = false ; |