How would you find out if a hard drive type is GPT or MBR with C#? I looked at Win32_DiskDrive and that doesn't seem to have it.
Asked
Active
Viewed 1,156 times
0
-
You might find this interesting: http://stackoverflow.com/questions/3840870/detect-gpt-and-mbr-partitions-with-powershell – dcaswell Aug 29 '13 at 03:30
1 Answers
2
You'd want to use PInvoke (see http://pinvoke.net) with CreateFile
, DeviceIoControl
(dwIoControlCode = IOCTL_DISK_GET_PARTITION_INFO_EX
), and the PARTITION_INFORMATION_EX
structure's PartitionStyle
field will tell you (PARTITION_STYLE_MBR
, PARTITION_STYLE_GPT
or PARTITION_STYLE_RAW
).

Plymouth223
- 1,905
- 1
- 12
- 22