Reputation: 129
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.
Upvotes: 0
Views: 1299
Reputation: 1925
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
).
Upvotes: 3