Link to home
Start Free TrialLog in
Avatar of Edarn
Edarn

asked on

How do I enumerate the available USB ports in C#

Hi!

Hi!

Is there any easy way to get hold of the usb ports that are available on my computer?
Currently I have some external tool that when running it I can see in a log that it uses for example EPIUSB2. Can I list the existing ports somehow?

Kind regards
Thomas Hermansson
Avatar of TheAvenger
TheAvenger
Flag of Switzerland image

From another article:

"USB ports don't have names. It is a bus, it doesn't matter what connector you use. Just like it doesn't matter where you plug in a card in the bus inside of the machine."

So you can get the attached devices, not the USB ports themselves. Getting a list of connected devices: http://code.google.com/p/usb-devices-list/
Avatar of Edarn
Edarn

ASKER

Hi!

Thanks, but that source seems not to work I´m afraid. :-/
ASKER CERTIFIED SOLUTION
Avatar of TheAvenger
TheAvenger
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Edarn

ASKER

I get:
Error: Additional information: Unable to cast object of type USBDevicesList.core.chub to USBDevicesList.Core.CDevice.

This happens in line 67 of CGenerateReport.

You might need to review the code and fix it. But a lot of sources point to it, so it should be worth.
Avatar of Edarn

ASKER

I couldn´t get the source code to work on my computer. Will investigate later on what needs to be done, but I belive the code will be sufficiant for me to use.

kind regards
Thomas