tags:

views:

56

answers:

3

Hello

To get the removable drives i have used GetDriveType ( ) function

Is it possible to check whether a drive is floppy drive or not ?

Please let me know your suggestions on this...

Thank you dor any help

A: 

The best chance that I know of is to check if the drive letter is A: or B:. I haven't tried attaching three USB floppy drives to one PC so I don't know if a floppy might have a higher drive letter. Other quirks are possible too. But this test is nearly reliable enough for some purposes.

Windows programmer
This is just wrong. I've seen many computers where `A:` was mapped to a network drive or even a real physical hard-drive.
ereOn
This is bad advice - any type of drive can have any drive letter in Windows.
JBRWilkinson
JBRWilkinson, it looks like you're right sometimes. http://support.microsoft.com/kb/307844/en-us, "Drive letters A and B are reserved for floppy disk drives. However, if your computer does not have a floppy disk drive, you can assign these letters to removable drives." Oddly on my computers that don't have floppies Windows still reserved letters A and B for floppies, except when other quirks occured as mentioned in my posting.
Windows programmer
+2  A: 

It's possible - have a look at the following Microsoft Knowledge Base Article.

humbagumba
+1: I was just about to post the very same link ;) However, please note that this guaranteed only for Windows OSes up to Windows XP.
ereOn
+3  A: 

Internally Microsoft Windows hold so named characteristics flags (defined in wdm.h) for every device. If device which corresponds the drive letter has flag FILE_FLOPPY_DISKETTE, then the drive is a floppy drive:

//
// Define the various device characteristics flags (defined in wdm.h)
//
#define FILE_REMOVABLE_MEDIA                    0x00000001
#define FILE_READ_ONLY_DEVICE                   0x00000002
#define FILE_FLOPPY_DISKETTE                    0x00000004
#define FILE_WRITE_ONCE_MEDIA                   0x00000008
#define FILE_REMOTE_DEVICE                      0x00000010
#define FILE_DEVICE_IS_MOUNTED                  0x00000020
#define FILE_VIRTUAL_VOLUME                     0x00000040
#define FILE_AUTOGENERATED_DEVICE_NAME          0x00000080
#define FILE_DEVICE_SECURE_OPEN                 0x00000100
#define FILE_CHARACTERISTIC_PNP_DEVICE          0x00000800
#define FILE_CHARACTERISTIC_TS_DEVICE           0x00001000
#define FILE_CHARACTERISTIC_WEBDAV_DEVICE       0x00002000

To get characteristics flags of a drive you can use different API functions. I find as a most effective and simple way to use NtQueryVolumeInformationFile function from ntdll.dll. Under http://stackoverflow.com/questions/3098696/how-to-get-the-vid-pid-and-drive-letter-for-all-the-usb-mass-storage-devices-plug/3100268#3100268 you will find an example of usage of this API.

UPDATE: You can use NtQueryVolumeInformationFile function directly without previous calls of IOCTL_STORAGE_GET_DEVICE_NUMBER and IOCTL_STORAGE_QUERY_PROPERTY which was called in the example for another reasons.

UPDATED 2: By the way the usage of GetDriveType to test if a drive is removeable is not safe. I have many removable hardware where GetDriveType show the drive as non removeable, but characteristics flags has do has FILE_REMOVABLE_MEDIA bit set. Usage of SetupDiGetDeviceRegistryProperty with SPDRP_REMOVAL_POLICY is also safe. In the last case you should test for CM_REMOVAL_POLICY_EXPECT_SURPRISE_REMOVAL or CM_REMOVAL_POLICY_EXPECT_ORDERLY_REMOVAL like I do this in the example http://stackoverflow.com/questions/3098696/how-to-get-the-vid-pid-and-drive-letter-for-all-the-usb-mass-storage-devices-plug/3100268#3100268.

Oleg
+1 from me Yoda!
Andreas Magnusson