|
Func _GetDrivePartitionStyle($sDrive)
Local $tDriveLayout = DllStructCreate('dword PartitionStyle;' & _
'dword PartitionCount;' & _
'byte union[40];' & _
'byte PartitionEntry[8192]')
Local $hDrive = DllCall("kernel32.dll", "handle", "CreateFileW", _
"wstr", "\\.\" & $sDrive, _
"dword", 0, _
"dword", 0, _
"ptr", 0, _
"dword", 3, _ ; OPEN_EXISTING
"dword", 0, _
"ptr", 0)
If @error Or $hDrive[0] = Ptr(-1) Then Return SetError(@error, @extended, 0) ; INVALID_HANDLE_VALUE
DllCall("kernel32.dll", "int", "DeviceIoControl", _
"hwnd", $hDrive[0], _
"dword", 0x00070050, _
"ptr", 0, _
"dword", 0, _
"ptr", DllStructGetPtr($tDriveLayout), _
"dword", DllStructGetSize($tDriveLayout), _
"dword*", 0, _
"ptr", 0)
DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hDrive[0])
Switch DllStructGetData($tDriveLayout, "PartitionStyle")
Case 0
Return "MBR"
Case 1
Return "GPT"
Case 2
Return "RAW"
Case Else
Return "UNKNOWN"
EndSwitch |
|