欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2023-12-19 13:07:04
复制代码 代码如下:private void usbport_usbdeviceattached(objectsender,usbclass.usbdeviceeventa...

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

复制代码 代码如下:

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

上一篇:

下一篇: