首页 > 编程 > C# > 正文

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

2020-01-24 02:43:19
字体:
来源:转载
供稿:网友



复制代码 代码如下:

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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表