How to determine the type of disk?

I am trying to figure out the type of device for a specific drive. I would like to know how to do this on Mac OS X and Linux, but for now, if that is enough for a Windows solution.

So, let's say I have drive H. I can determine if the device is a removable drive through the Get API function for Win32 (GetDriveType ()). I can also find this on Mac OS X.

But I can’t find the type of device in a reliable way. For example, this is a USB drive, portable hard disk (PHD), etc.

Digging through registries in Windows, I also can not find much information. Although I would prefer to use some APIs for this, if possible, I will use the registry if necessary.

Currently I'm interested ... is it a flash drive drive (so I can show the Usb flash drive icon in my program) or a portable hard drive (so the PHD icon will be displayed).

+3
source share
4 answers

Is the device class what you want? If so, you can try libusb ( available for win32). Use the function libusb_get_device_descriptor.

+1
source

For Windows, it looks like it SHGetFileInfocan do the trick. Perhaps you can call the root folder of the drive? See http://msdn.microsoft.com/en-us/library/bb762179(VS.85).aspx .

SH... , , Explorer ( , ) , Windows...

+3

DeviceIoControl IOCTL_STORAGE_QUERY_PROPERTY. , , USB, StorageDeviceProperty BusType. " ".

XP, , , , ​​.

+1

IOCTL_STORAGE_QUERY_PROPERTY, STORAGE_DEVICE_DESCRIPTOR. - STORAGE_BUS_TYPE enum, , (USB, 1394, RAID, ATAPI, SCSI, .)

+1

Source: https://habr.com/ru/post/1773521/


All Articles