I’ve read a lot articles and stackoverflow posts in the last days but now I’m more confused as in the beginning :D Maybe someone can clarify this a bit for me. In other stackoverlow posts (like Get List of connected USB Devices) they use a WMI query to get all connected devices. I use something like this to but I can't make a logical connection to a physical usb port. There seems no information in the query to identify this. Also I need a list of all disconnected devices respectively unused usb-ports.
I have the following problem to solve in C#:
I need to provide a list of all internal and external connected USB devices. I’ve started with getting the USB controllers with WMI (Win32_USBController), then I’ve got the USB devices (Win32_USBHub - Hub and connected devices, they seem to be treated as the same) and then I’ve made a connection with the antecedent and dependent properties of the Win32_USBControllerDevice class.
Now I’m struggling with the following questions that have to be answered first:
- Is there a definition for a USB-Port or is USB-Port just a colloquial description for just some endpoint of a bus?
- If there is a definition, how can I list it with C#? Is WMI generally the right way or should I use something else?
- After all this, can I say something like “This internal hub is connected to a host controller and has 8 ports. Port 1-3 are disconnected, port 4 is connected with a cherry keyboard and port 5-8 are disconnected”
Thank you very much in advance
Michael