user2526047
user2526047

Reputation: 129

Find out if HDD is GPT or MBT in C#

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

Answers (1)

Plymouth223
Plymouth223

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

Related Questions