PDA

View Full Version : Detect Drive Type - External?



NewsArchive
06-02-2011, 11:11 PM
Is there a way to determine a drive is external?
Get Drive Type returned Drive_Fixed for an external (USB) drive but I'd
like to be able to tell it is external.

TIA,
Rick

NewsArchive
06-02-2011, 11:11 PM
If you look in Windows Explorer on that computer, does the USB drive show up
in the "Hard Disk Drives" section or in the "Devices with Removable Storage"
section?

Jane Fleming

NewsArchive
06-02-2011, 11:12 PM
Does this help any?

http://www.codeproject.com/KB/winsdk/usbdisks.aspx

Maybe a support dll could be made?

Jeff Slarve
www.jssoftware.com
www.twitter.com/jslarve

NewsArchive
06-02-2011, 11:12 PM
> Does this help any?
>
> http://www.codeproject.com/KB/winsdk/usbdisks.aspx

Interesting....!

Friedrich

NewsArchive
06-02-2011, 11:13 PM
A USB Stick comes back as a removable drive, from DriveType

A hard drive in an external case using a USB interface comes back as a
fixed drive but the code in the article Jeff pointed out does return the
interface as USB. http://www.codeproject.com/KB/winsdk/usbdisks.aspx

A hard drive in an external case using eSata interface returns ata or sata
as the interface type. It's interesting that eSata isn't in the list of
interfaces for the API.

So close and maybe good enough. I'll do a little more digging.

Thanks,
Rick

NewsArchive
06-02-2011, 11:13 PM
Ricks next cmag article :)

Jeff Slarve
www.jssoftware.com
www.twitter.com/jslarve

NewsArchive
06-02-2011, 11:14 PM
Rick,

> Is there a way to determine a drive is external?
> Get Drive Type returned Drive_Fixed for an external (USB) drive but I'd
> like to be able to tell it is external.

The "Get System Information (Drive Type)" script function is a wrapper
around the GetDriveType Windows API:

http://msdn.microsoft.com/en-us/library/aa364939(v=vs.85).aspx

So if that Windows API returns "DRIVE_FIXED" then (for Windows) the drive
has fixed media; for example, a hard drive or flash drive. Otherwise, it
would return "DRIVE_REMOVABLE" (for removable drives).

Friedrich