Tôi cần biết loại thiết bị USB nào hiện đang được sử dụng trong hệ thống. Có một số USB specification về mã lớp của thiết bị USB. Nhưng tôi không thể nhận được loại thiết bị, yêu cầu WMI WQL: select * from Win32_UsbHub
cung cấp giá trị null trên mã Lớp, mã Lớp con, trường Loại giao thức. Bất kỳ ý tưởng làm thế nào để phát hiện loại thiết bị USB hiện đang được sử dụng?C# phát hiện thiết bị USB ClassCode (loại thiết bị usb)
mã hiện tại của tôi:
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
}
}
Bạn có thể gửi các ví dụ đầy đủ bao gồm 'ManagementScope', 'ObjectQuery' và' ManagementObjectSearcher' sử dụng? – SwDevMan81
ManagementObjectThu thập sưu tập; sử dụng (var searcher = new ManagementObjectSearcher (@ "Chọn * Từ Win32_USBHub")) collection = searcher.Get(); – MelnikovI
Công cụ wbemtest.exe cho cùng một hiệu ứng: 'Class cod, Subclass code, trường Protocol type' là null – MelnikovI