I am currently developing a program to check if a USB device has been detected on a specific USB hub in C#. I know the PID and VID of both the hub and the slave device connected to the hub.
I am doing this using a ManagementObjectSearcher Query to get the devices:
ManagementObjectSearcher USBSearchQuery = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_PnPEntity WHERE DeviceID LIKE \"%VID_17EF&PID_6019%\"");
ManagementObjectCollection DeviceCollection = USBSearchQuery.Get();
This works quite fine. The ManagementObjectCollection DeviceCollection contains 2 elements. One HID device and one USB device. When I check with the device manager, I see the elements and can access the property Parent, but it seems to be impossible to get either the parent or the children of an object through a WMI query.
I could do this either through the children of the hub or the parent of the device. Do any of you have an idea how to do this?