My coworker asked me to help with following problem. He has an USB mass storage device with known VID and PID. He needs to find appropriate disk device, ideally some supported way using Setup API. Example:
Device: USB\VID_0457&PID_0151\000000000005A8
Description: USB Mass Storage Device
Service: USBSTOR
Status: enabled (status 180600a)
Device: USBSTOR\DISK&VEN_FLASH&PROD_DRIVE_UT_USB20&REV_0.00\000000000005A8&0
Description: Disk drive
Name: Flash Drive UT_USB20 USB Device
Service: disk
Status: enabled (status 180200a)
There is a relationship between these two devices. The Device Manager displays them as parent and child and also Device Tree does. But how to find this relationship programatically? I guess CM_GetParent() would work but it seems CfgMgr API is deprecated.
Currently he has some suspicious code which enumerates GUID_DEVINTERFACE_USB_DEVICE, searches HW IDs for VID and PID and when the device is found, extracts the last part (instance ID?) which is 000000000005A8 in above example. Then the code enumerates GUID_DEVINTERFACE_DISK and tries to find extracted string in HW IDs. It works but we really dislike it. Is there some better way?
Thanks.
Best regards,
Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]
>relationship programatically? I guess CM_GetParent() would work but it seems
CfgMgr API is deprecated.
So what? No other ways. Look at DEVCON - can it print trees? does it using
deprecated APIs for this?
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
> ----------
From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of Maxim S. Shatskih[SMTP:xxxxx@storagecraft.com]
Reply To: Windows System Software Devs Interest List
Sent: Sunday, September 10, 2006 7:48 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] How to find disk device using USB VID and PID
>relationship programatically? I guess CM_GetParent() would work but it seems
>CfgMgr API is deprecated.
So what? No other ways. Look at DEVCON - can it print trees? does it using
deprecated APIs for this?
That’s what I was asking for: if there isn’t other way. Well, there isn’t and we decided to use deprecate APIs and HW IDs parsing, too. In the Setup API world it is very easy to miss something and it is better to ask. The best thing would be if MS makes this API clean, improve documentation and include graph of relations between individual functions. They should also use Google to find what related problems developers have to solve and provide solutions. Only a dream, I know.
Best regards,
Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]