我需要知道当前系统中使用了哪种类型的USB设备。关于USB设备的类别码,有一个USB规范。但是我无法获取设备类型,WMI请求 WQL: select * from Win32_UsbHub
在类别码、子类别码、协议类型字段上返回空值。您有什么想法可以检测当前正在使用的USB设备类型吗?
我目前的代码:
ManagementObjectCollection collection;
using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_USBHub"))
{
collection = searcher.Get();
foreach (var device in collection)
{
var deviceId = (string)GetPropertyValue("DeviceID");
var pnpDeviceId = (string)GetPropertyValue("PNPDeviceID");
var descr = (string)device.GetPropertyValue("Description");
var classCode = device.GetPropertyValue("ClassCode"); //null here
}
}
Class cod, Subclass code, Protocol type
字段为空。 - MelnikovI