2

In windows programming, how can we find out the number of partitions and the name of each partition on the hard drive?

Chibueze Opata
  • 9,856
  • 7
  • 42
  • 65
user1232138
  • 5,451
  • 8
  • 37
  • 64

2 Answers2

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