How to differentiate a floppy drive and a USB drive in VC++?
-
Hi, how to differentiate a floppy drive and a USB drive in VC++ , i used GetDriveType and both have REMOVABLE property , and can some one explain how exactly to use "SetupDiGetDeviceRegistryProperty" to determine whether it's USB or FLOPPY
-
you could also use windows registry entry and settings to fetch values for hardware devices. :)
-
Hi, how to differentiate a floppy drive and a USB drive in VC++ , i used GetDriveType and both have REMOVABLE property , and can some one explain how exactly to use "SetupDiGetDeviceRegistryProperty" to determine whether it's USB or FLOPPY
You can issue the IOCTL_STORAGE_GET_MEDIA_TYPES_EX to differentiate. Here is an example code:
//////////////////////////////////////////
DWORD dwOutBytes;
HANDLE hDevice = CreateFile(_T("\\\\.\\A:"), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);if (hDevice != INVALID_HANDLE_VALUE)
{
DEVICE_MEDIA_INFO dmi;
DeviceIoControl(hDevice,
IOCTL_STORAGE_GET_MEDIA_TYPES_EX,
NULL, 0,
&dmi, sizeof(dmi),
dwOutBytes,
NULL);if ((MEDIA\_TYPE)dmi.RemovableDiskInfo.MediaType == RemovableMedia) { //USB disk } else { //Floppy }
}
CloseHandle(hDevice);
//////////////////////////////////////////
Hope it is useful to you.
Working is a happy thing! Enjoy the free partition manager.