0

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

Community
  • 1
  • 1
Michael Kambeck
  • 87
  • 3
  • 10
  • 1
    Possible duplicate of [Get List of connected USB Devices](http://stackoverflow.com/questions/3331043/get-list-of-connected-usb-devices) – Hamid Pourjam Apr 26 '16 at 07:01
  • @dotctor The possible duplicate supplies a solution for listing all connected devices and that is the solution I'm already using. But that only covers 50% of my problem because I'm searching for a solution to monitor not only the devices that are plugged in but also the ports that doesn't have a device plugged in. – Michael Kambeck Apr 26 '16 at 08:25
  • 1
    You might need to use SetupAPI to get that level of information. (I don't know much about WMI's USB support.) – David Grayson Apr 26 '16 at 22:21
  • 1
    @cwtrsld: Have you seen this? [Can the physical USB port be identified programatically for a device in Windows?](http://stackoverflow.com/questions/6416931/can-the-physical-usb-port-be-identified-programatically-for-a-device-in-windows) – Clijsters Apr 28 '16 at 20:34

0 Answers0