Re: How to make link between USB physical port and drive letter mount by windows

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




All I've written is for user mode.

You get a parent device by CM_Get_Parent and the
driver key name by CM_Get_DevInst_Registry_Property
called with CM_DRP_DRIVER.

Using CM_xxx functions is not suggested by MS, but
they are so easy too use...


Uwe



max_mont wrote:
Thank you very much for your help. But I'm a newbie in driver
development (I usually develop in higer level).
I don't see how I can get parent device and get "driver key name).

Have you got a piece of code ?

Many thanks in advance again.



On 10 juin, 09:12, Uwe Sieber <m...@xxxxxxxxxxxxx> wrote:
max_mont wrote:

I would like to enumerate all USB storage plugged on a PC, identify
all by physical port and by drive letter.
I can enumerate all USB device with DDK sample (usbview) but I can't
manage to find drive letter for each storage.
You need an enumeration of all VOLUMES. Get their device
numbers. The enumerate all DISKs, CDROMs and FLOPPYs. Match
them with the volumes by their device numbers. I've shown
this here:http://www.codeproject.com/system/RemoveDriveByLetter.asp

For each drive with BusType==BusTypeUsb get the parent
device of the DISK/CDROM/FLOPPY which is the USB device
itself. Get their "driver key name" (SPDRP_DRIVER / CM_DRP_DRIVER).

Match it with the driver key name of the USB devices found
thru the USB API (IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME).

Good luck :-)

Uwe

.



Relevant Pages