C#教程

关注公众号 jb51net

关闭
首页 > 软件编程 > C#教程 > c#检测usb设备

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

作者:

这篇文章主要介绍了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;
}
}

您可能感兴趣的文章:
阅读全文