In windows programming, how can we find out the number of partitions and the name of each partition on the hard drive?
Asked
Active
Viewed 247 times
2
-
Have a look at: http://stackoverflow.com/q/286534/1250303. – Java42 Mar 15 '12 at 14:36
2 Answers
3
You can use the DeviceIoControl function with the IOCTL_DISK_GET_DRIVE_LAYOUT_EX contol code to get a list of partitions.
RRUZ
- 134,889
- 20
- 356
- 483
1
There's a very good article on how to do this at MSDN. It utilizes the GetLogicalDrives, GetLogicalDriveStrings, GetDriveType, and GetVolumeInformation functions. You can download the source from here.
Chibueze Opata
- 9,856
- 7
- 42
- 65