How do I query for USB devices not listed in USB Root Hub

萝らか妹 提交于 2020-02-28 07:59:11

问题


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.



来源:https://stackoverflow.com/questions/22235656/how-do-i-query-for-usb-devices-not-listed-in-usb-root-hub

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!