How to get USB flash disk drive letter(s)?

My coworker tries to solve following problem. We have an USB flashdisk with known VID and PID. He wants to find all drive letters for this devices and it is necessary to ignore other flashdisks attached. Currently he uses following method:

  • call GetVolumeNameForVolumeMountPoint() function for all drive letters from A to Z and make a list of volume names
  • call SetupDiGetClassDevs() for GUID_DEVINTERFACE_VOLUME
  • for every device in the list get grandparent device and get device ID for it
  • compare this device ID with device ID for know VID+PID
  • for matching devices call GetVolumeNameForVolumeMountPoint() function and compare volume name with a list from the first step. If there is a match, drive letter is found.

The method seems to work but there are disadvangates. We’d need it works at wME, too, and function GetVolumeNameForVolumeMountPoint() isn’t supported there. Next, it seems too fragile to me. It depens on exact storage stack form (grandparent device). Does anybody know better way how to achieve this goal? Preferably which’d work also at wME as we still have to support this abomination.


Best regards,

Michal Vodicka
UPEK, Inc.