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

2019-05-10 06:36发布

问题:

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.

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'?

回答1:

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.



标签: wmi