c#检测usb设备拨插类库USBClassLibrary分享
程序员文章站
2024-02-22 23:36:10
复制代码 代码如下:private void usbport_usbdeviceattached(objectsender,usbclass.usbdeviceeventa...
复制代码 代码如下:
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;
}
}
上一篇: SQLServer 之 树查询