I feel somewhat noob yet with this of getting the Information of Hardware of the CPU, so i come with this request: Hard Drive, CD/DVD/Bluray reader, Floppy and if it's possible USB. I've been looking on MSDN GetDriveType but seems i'm bad at searching or i don't understand it. Any idea?
How can I determine the type of a particular drive?
5.9k views Asked by Kazuma At
3
There are 3 answers
0
On
The only all-in-one API I know of for Windows with that information is WMI, but it's not terribly simple to use. On the other hand, many programs communicate with devices directly, using pass-through control codes, or I/O control codes like SMART_RCV_DRIVE_DATA.
(I don't know how Speccy works, but I'm guessing it uses a combination of these methods to get the system info needed.)
1
On
If you want to determine that a device is USB device, you can open its handle and send IOCTL queries using DeviceIoControl() to get bus type a device is connected to.
EnumUsbDrivesLetters - the post is in Russian but it contains C++ source code, so the matter could be understood easily.
Cheers, Andriy
I'm not sure what you didn't understand about the documentation you linked to...
The sole argument accepted by the function is the root directory of the drive you want to get information about (including a trailing backslash). The function returns a value indicating which type of drive that is. A chart is shown that gives the possible return values and what each of them mean.
For example:
It also says that if you want to determine whether a drive is a USB-type drive, you need to call the
SetupDiGetDeviceRegistryProperty
function and specify theSPDRP_REMOVAL_POLICY
property.