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,698
  • 7
  • 41
  • 65
user1232138
  • 5,301
  • 5
  • 35
  • 61

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
  • 133,023
  • 16
  • 348
  • 476
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,698
  • 7
  • 41
  • 65