How do I query for USB devices not listed in USB R

2019-05-10 06:57发布

Query which works for some devices found in Win32_USBHub

SELECT * FROM Win32_USBHub WHERE DeviceID = '{0}'

Here's the code context,

// Check if USB device is plugged in
string deviceQuery = String.Format("SELECT * FROM Win32_USBHub WHERE DeviceID = '{0}'", deviceID);
using (var searcher = new System.Management.ManagementObjectSearcher(deviceQuery))
    if (searcher.Get().Count == 0)
        MessageBox.Show(@"Device not detected");

However when a device is not listed inside 'Universal Serial Bus controllers', querying from Win32_USBHub does not return the connected device I'm looking for.

USB Device

Is there another 'table' to query outside from Win32_USBHub which would contain device I'm looking for 'Cardio Perfect PRO-Link USB'? Or would this be a 'custom table'?

标签: wmi
1条回答
爷、活的狠高调
2楼-- · 2019-05-10 07:21
SELECT * FROM Win32_PnPEntity WHERE DeviceID = '{0}'

I guess I didn't search long enough, here's a link which contains a lot of really good examples... http://msdn.microsoft.com/en-us/library/aa394587%28v=vs.85%29.aspx

The 'table' I was looking for is Win32_PnPEntity it listed all 155 devices I'm connected to.

查看更多
登录 后发表回答