title: Get the partition type of a specific partition in C++, on a GPT disk
body: <p>I'm working on a project which requires me to operate at a low level on Windows drives, and am doing so primarily using Windows API calls. But before I can operate on the drive, I need to know the types of partitions present on it.</p>
  
  <p>This is fairly simple on a disk formatted by MBR, because</p>
  
  <pre><code>DeviceIoControl(...,IOCTL_DISK_GET_DRIVE_LAYOUT_EX,...);
  </code></pre>
  
  <p>returns a structure in format <code>DRIVE_LAYOUT_INFORMATION_EX</code>, which contains an array of <code>PARTITION_INFORMATION_EX</code>. On an MBR disk, the <code>PARTITION_INFORMATION_EX.Mbr.PartitionType</code> element contains a unique identifier for the partition type, e.g. for <code>NTFS</code> it is <code>0x07</code>, for <code>Extended</code> it is <code>0x05</code>.</p>
  
  <p>However, this isn't so simple on a GPT disk. <em>I know that I can read the identifier off of the beginning of the partition</em>, but I'd prefer to handle this with API calls, such as <code>DeviceIoControl</code>.  When I run <code>DeviceIoControl</code> on a GPT disk, the <code>PARTITION_INFORMATION_EX.Mbr.PartitionType</code> contains completely different values than those which would be normally there.</p>
  
  <p><strong>Note that the GUID is useless to me because that only tells me the purpose of the partition, not what type of partition it is.  I'm trying to figure out if the drive is NTFS, FAT, etc.</strong></p>