当前位置: 编程技术>.net/c#/asp.net
c#检测usb设备拨插类库USBClassLibrary分享
来源: 互联网 发布时间:2014-10-29
本文导语: 代码如下:private void USBPort_USBDeviceAttached(objectsender,USBClass.USBDeviceEventArgs e){if (!MyUSBDeviceConnected){if(USBClass.GetUSBDevice(MyDeviceVID, MyDevicePID,ref USBDeviceProperties, false)){ //My Device is connectedMyUSBDeviceConnected = true;}}}private void USBPort_USBDeviceRemo...
代码如下:
private void USBPort_USBDeviceAttached(objectsender,
USBClass.USBDeviceEventArgs e)
{
if (!MyUSBDeviceConnected)
{
if(USBClass.GetUSBDevice(MyDeviceVID, MyDevicePID,
ref USBDeviceProperties, false))
{
//My Device is connected
MyUSBDeviceConnected = true;
}
}
}
private void USBPort_USBDeviceRemoved(objectsender,
USBClass.USBDeviceEventArgs e)
{
if(!USBClass.GetUSBDevice(MyDeviceVID, MyDevicePID,
ref USBDeviceProperties, false))
{
//My Device is removed
MyUSBDeviceConnected = false;
}
}