Würde gerne per WinAPI eine Partition MBR/Legacy als Aktiv setzen.
Für dieses Vorhaben stoß ich auf diese Seite:
https://forums.mydigitallife.net/thread ... ive.45729/
Der Code basiert auf den Aufruf "IOCTL_DISK_GET_DRIVE_LAYOUT_EX" und "IOCTL_DISK_SET_DRIVE_LAYOUT_EX".
Purebasic hat zu diesen Api-Aufrufe leider nicht viel zu bieten. Das Einzige was ich darüber gefunden hab ist das hier:
https://www.purebasic.fr/english/viewtopic.php?p=220673
Dieser PB-Code zeigt die Partition-Informationen nicht an.
Einen funktionierenden Au3 Code gibt es hier:
https://www.autoitscript.com/forum/topi ... layout_ex/
Wie kann ich als ersten Schritt die Partitioninfos anzeigen lassen ?
Code: Alles auswählen
Structure PARTITION_INFORMATION_GPT Align #PB_Structure_AlignC
Partitiontype.GUID
PartitionId.GUID
Attributes.q
Name.b[36]
EndStructure
Structure PARTITION_INFORMATION_MBR Align #PB_Structure_AlignC
PartitionType.b
BootIndicator.b
RecognizedPartition.b
HiddenSectors.l
EndStructure
Structure PARTITION_INFORMATION_EX Align #PB_Structure_AlignC
PartitionStyle.l
StartingOffset.LARGE_INTEGER
PartitionLength.LARGE_INTEGER
PartitionNumber.l
RewritePartition.b
StructureUnion
ppmbr.PARTITION_INFORMATION_MBR
ppgpt.PARTITION_INFORMATION_GPT
EndStructureUnion
EndStructure
Structure DRIVE_LAYOUT_INFORMATION_GPT Align #PB_Structure_AlignC
DiskId.GUID
StartingUsableOffset.LARGE_INTEGER
UsableLength.LARGE_INTEGER
MaxPartitionCount.l
EndStructure
Structure DRIVE_LAYOUT_INFORMATION_MBR
Signature.l
EndStructure
Structure DRIVE_LAYOUT_INFORMATION_EX Align #PB_Structure_AlignC
PartitionStyle.l
PartitionCount.l
StructureUnion
pdmbr.DRIVE_LAYOUT_INFORMATION_MBR
pdgpt.DRIVE_LAYOUT_INFORMATION_GPT
EndStructureUnion
PartitionEntry.PARTITION_INFORMATION_EX[255]
EndStructure
pdl.DRIVE_LAYOUT_INFORMATION_EX
#IOCTL_DISK_BASE = 7
#METHOD_BUFFERED = 0
#FILE_ANY_ACCESS = 0
Procedure.l CTL_CODE(DeviceType, Function, Method, Access)
ProcedureReturn ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method)
EndProcedure
IOCTL_DISK_GET_DRIVE_LAYOUT_EX = CTL_CODE(#IOCTL_DISK_BASE,$14,#METHOD_BUFFERED,#FILE_ANY_ACCESS)
hDrive.l = CreateFile_("\\.\PHYSICALDRIVE0", #GENERIC_READ|#GENERIC_WRITE,#FILE_SHARE_READ|#FILE_SHARE_WRITE,0,#OPEN_EXISTING,0,0)
DeviceIoControl_(hDrive,IOCTL_DISK_GET_DRIVE_LAYOUT_EX,0,0,@pdl,SizeOf(pdl),@ret.l,0)
Debug ret
Debug "Partition count: "+Str(pdl\PartitionCount)
Debug pdl\PartitionStyle
If pdl\PartitionStyle=0: Debug "MBR": EndIf
If pdl\PartitionStyle=1: Debug "GPT": EndIf
If pdl\PartitionStyle=2: Debug "RAW": EndIf
If pdl\PartitionStyle=>3: Debug "unknow": EndIf
Debug "MBR Signature"+Hex(pdl\pdmbr\Signature)
Debug pdl\PartitionEntry
Debug "---------------------"
;Debug Str(pdl\PartitionEntry[1]\ppmbr\RecognizedPartition)
Debug pdl\PartitionEntry\StartingOffset
;Debug pdl\PartitionEntry[0]\ppmbr\PartitionType
;Debug pdl\PartitionEntry\StartingOffset
;Debug pdl.partitionentry\
;ShowMemoryViewer(pdl\PartitionEntry,1024)
;Debug pdmbr
CloseHandle_(hDrive)
Grüße