How to detect the USB ports?

Hi everybody,
My question is about how to detect the USB ports available on my system (eventually I want to know the one that are used and how they are used: by a mouse, a keyboard, a key, etc.), does any one know if there is an API function doing this.
Thanks.
[279 byte] By [FaresDZ] at [2007-11-20 9:20:18]
# 1 Re: How to detect the USB ports?
No. There is no API function. You can read the information from the registry.

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USB

It can also be Set002, etc.
cilu at 2007-11-11 4:12:38 >
# 2 Re: How to detect the USB ports?
Hi Cilu,

Thank you so much for your reply, I went to my registry and did check the key,
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USB
I found 13 sub-keys
ROOT_HUB
ROOT_HUB20
Vid_0000&Pid_0000
Vid_0556&Pid_0001
Vid_0556&Pid_0001&MI_00
...
etc.

I don't know what does this mean, I have only 4 USB entries on my computer.

Can you light me please?

Thanks.
FaresDZ at 2007-11-11 4:13:38 >
# 3 Re: How to detect the USB ports?
Ok,, If you plug in a device , you can see the new device modem or port getting populated with a new device information.

Right click that device and check the properties, you can see the ones whhich you have listed and this gives you some idea to initiate.

So in other words, to locate a particular device and connect programatically, you can go exactly to that registry place, read the registry for the PID and the VID values and then use the COM port technique to read and write data :wave:
VCVCVC at 2007-11-11 4:14:40 >