Software differentiation of USB floppy drive and USB flash drive in Windows

On Windows (XP-7), is there a reliable way to program differentiate USB floppy disks and USB flash drives in C ++?

I am currently using WMI to receive updates when new Win32_LogicalDisk instances are Win32_LogicalDisk , and then using the DriveType attribute of the LogicalDisk object to determine the base type. This works quite well, except that floppy drives and USB sticks are DriveType DRIVE_REMOVABLE , so to distinguish between these (floppy vs. flash), I use IOCTL_STORAGE_GET_HOTPLUG_INFO to find out if the device is hotpluggable, and worked on the director, which meant that it was a flash drive, not a floppy disk. Again, I think this works pretty well (if a little inefficient, using both the WDK API and WMI to get information) in the case of internal floppy disks, but, unfortunately, USB floppy disks are also very convenient for connecting to a mobile phone, so there is no clear way to distinguish between flash drives and USB floppy disks that I see. I know that there are properties that can work, for example, checking whether they match the reserved A: or B drives (editing: only relevant if the machine definitely has a floppy drive - see MS-KB: how to change the letter assignment in Windows XP ), or look at the description, but I would like something more reliable.

Sorry for the long explanation, but just want to be clear! Thanks

+7
c ++ wmi usb wdk floppy
source share
4 answers

Have you tried Win32_LogicalDisk.MediaType? It has specific enumerations for floppy disks. Make sure you try it when there is no disk in the drive.

+5
source share

At the USB level, there is no way to distinguish between a regular keyboard drive and a USB floppy. What the window itself means cannot reliably say what it is.

There are some tips you can put together: Floppies should: a. Have a CBI / CB b storage protocol. SCSI UFI

BUT, in the world of USB devices, everyone does whatever they want. The only test is: "Does it work on windows." And Windows just checks the size, if its USB device with removable media and the usual size of floppy disks, it will consider it a floppy disk.

This is not the case with a β€œreal” floppy disk, but with a connected USB there is no definite path.

+5
source share

You can use the β€œSize” attribute (USB> 1.4MB), it does not look like there is a chance to find a 1.4 MB flash drive in the near future.

+4
source share

The obvious property to check is IOCTL_DISK_GET_DRIVE_GEOMETRY . This gives you (among other things) a MEDIA_TYPE . Everything except RemovableMedia and FixedMedia is flexible.

+3
source share

All Articles