0

I am on windows 7 and installed python 3.5. I would like to know if the disk/ partition supplied to the program is GPT or not. I am aware of the gdisks windows package and my attempt to use it made my USB disk corrupt. I need to just find the type of disk and I am not going to carry out any operation on it. Is there a way to find it under python? Any help is appreciated...

user247702
  • 23,641
  • 15
  • 110
  • 157
sundar_ima
  • 3,604
  • 8
  • 33
  • 52
  • You might be able to execute the Windows `diskpart` command and pass it a script (text file) with the commands "list disk" in it. This produces output showing which disks are GPT which could then be parsed. See [this answer](https://stackoverflow.com/a/35691056/355230) which shows the format of the output. – martineau Nov 05 '17 at 13:48
  • From what I've just found, you could call the Windows [`DeviceIoControl`](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363216(v=vs.85).aspx) function and pass it the control code [`IOCTL_DISK_GET_PARTITION_INFO_EX`](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365180(v=vs.85).aspx) to get a [`PARTITION_INFORMATION_EX`](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365448(v=vs.85).aspx) structure back that contains a field named `PartitionStyle` that has the information you want. – martineau Nov 05 '17 at 14:05
  • The previous suggestion looks good . Can you give some sample code for second suggestion so that I can accept it as an answer. – sundar_ima Nov 05 '17 at 16:09

0 Answers0