Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top