Hi All,
Is it possible to find the type of device that is connected to USB port. I
wanted to findout whether the attached device is external driver or mp3
player or any specific device data.
Any information is helpful.
Thanks,
Kedar.
Hi All,
Is it possible to find the type of device that is connected to USB port. I
wanted to findout whether the attached device is external driver or mp3
player or any specific device data.
Any information is helpful.
Thanks,
Kedar.
You can use the SetupDi* API to query the hardware IDs and compatible IDs
from USB devices. In fact, that’s about the only way you can tell that it
*is* a USB device. Enumerate all devices, and look for devices whose
compatible IDs and hardware IDs begin with "USB". There are several forms
of these. Some identify devices based on their USB vendor and product IDs,
and these have the form USB\Vid_XXXX&Pid_YYYY, where XXXX is the vendor ID
and YYYY is the product ID, both encoded in hexadecimal. The Compatible Ids
value is built using the USB class/subclass/protocol of the device, and is
in the form USB\Class_XX&SubClass_YY&Prot_ZZ.
To see an example of these IDs, open Device Manager, open the property page
for a USB device, go to the Details tab, and select “Hardware Ids”. You’ll
see these. You’ll need XP SP2 to enable the Details tab.
This is a simplification, of course, but it’s not much more complicated than
that. To begin with, you’ll probably want to just enumerate *all* devices,
using SetupDiGetClassDevs, passing the DIGCF_ALLCLASSES flag. Then, for
each device returned in the info set, query its hardware IDs and compatible
IDs, and check for the type of device you are interested in.
However, please note that there is not a special “mp3 player” device class.
Most MP3 players enumerate as USB Mass Storage devices. But finding a USB
Mass Storage device is definitely not a guarantee that you’ve found an MP3
player. iPods enumerate as a tree of devices, the root device of which has
a PID/VID that identifies it as an Apple iPod. However, this will vary from
device to device, so, again, there is no magic “I’m an MP3 player” flag.
– arlie
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of kedar
Sent: Wednesday, April 05, 2006 11:36 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] finding USB device type
Hi All,
Is it possible to find the type of device that is connected to USB port. I
wanted to findout whether the attached device is external driver or mp3
player or any specific device data.
Any information is helpful.
Thanks,
Kedar.
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
> see these. You’ll need XP SP2 to enable the Details tab.
On older OSes - run CMD, say “set DEVMGR_SHOW_DETAILS=yes”, then run
“devmgmt.msc”. The same effect.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com