当前位置:主页 > 软件编程 > .NET代码 >

c#检测usb设备拨插类库USBClassLibrary分享

时间:2021-01-11 11:00:17 | 栏目:.NET代码 | 点击:



复制代码 代码如下:

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;
}
}

您可能感兴趣的文章:

相关文章