Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using Setup API to determine if a drive is on USB

518 views
Skip to first unread message

Andrew Jarvis

unread,
Jun 4, 2008, 7:57:23 AM6/4/08
to
Let me first say that I am NOT asking how to determine if a drive is USB. I
am already doing that using DeviceIoControl with
IOCTL_STORAGE_QUERY_PROPERTY.

***

The MSDN entry for the Win32 GetDriveType function says:

"To determine whether a drive is a USB-type drive, call
SetupDiGetDeviceRegistryProperty and specify the SPDRP_REMOVAL_POLICY
property."

I am curious about how this can be done as I cannot determine the
association between a drive letter and the device interface.

I can enumerate the USB devices with SetupDiEnumDeviceInterfaces and locate
my drive with physical device object name "\Device\USBPDO-7".

I can find the MS-DOS device name associated with the drive letter using
QueryDosDevice, which is "\Device\Harddisk1\DP(1)0-0+c".

This is where I get stuck.

How do I bridge the gap between the device interface and the drive letter?

Regards,
Andrew


Volodymyr M. Shcherbyna

unread,
Jun 4, 2008, 12:07:46 PM6/4/08
to
You can issue a series of IOCTLs to mount manager to obtain drive letter
having path in the form "\Device\USBPDO-7". There were a good example at
OSR, you could find original having the cached version:
http://74.125.39.104/search?q=cache:lFTt_X6TkAIJ:www.osronline.com/article.cfm%3Fid%3D107+QueryMountPoint+function&hl=fr&ct=clnk&cd=1&client=firefox-a

--
V.
This posting is provided "AS IS" with no warranties, and confers no
rights.
"Andrew Jarvis" <someone@somewhere> wrote in message
news:u9fwnojx...@TK2MSFTNGP04.phx.gbl...

Volodymyr M. Shcherbyna

unread,
Jun 4, 2008, 12:12:37 PM6/4/08
to
Ops, I ment "\Device\Harddisk1\DP(1)0-0+c" to drive letter.

--
V.
This posting is provided "AS IS" with no warranties, and confers no
rights.

"Volodymyr M. Shcherbyna" <v_sch...@online.mvps.org> wrote in message
news:OLdxi0lx...@TK2MSFTNGP05.phx.gbl...

Uwe Sieber

unread,
Jun 5, 2008, 12:39:40 PM6/5/08
to
Andrew Jarvis wrote:
> Let me first say that I am NOT asking how to determine if a drive is USB. I
> am already doing that using DeviceIoControl with
> IOCTL_STORAGE_QUERY_PROPERTY.
>
> ***
>
> The MSDN entry for the Win32 GetDriveType function says:
>
> "To determine whether a drive is a USB-type drive, call
> SetupDiGetDeviceRegistryProperty and specify the SPDRP_REMOVAL_POLICY
> property."

I think this is wrong. A removal policy
CM_REMOVAL_POLICY_EXPECT_SURPRISE_REMOVAL is
found on FireWire drives too.

Using IOCTL_STORAGE_QUERY_PROPERTY is the
right choice.

> I am curious about how this can be done as I cannot determine the
> association between a drive letter and the device interface.

The device numbers of the volume on the one side and of
disk/cdrom/floppy on the other side is the link.
I've shown this here (user mode):
http://www.codeproject.com/system/RemoveDriveByLetter.asp


Uwe

0 new messages