This is a work around with diskpart, because you can use diskpart with Windows, WinPE and WinRE.
Code : Tout sélectionner
Global Resultat$
Procedure Listdisk(Parameter)
prog = RunProgram("cmd.exe", "", "", #PB_Program_Open|#PB_Program_Read|#PB_Program_Write|#PB_Program_Hide)
If IsProgram(prog)
WriteProgramStringN(prog, "diskpart")
WriteProgramStringN(prog, "list disk")
WriteProgramStringN(prog, "exit")
WriteProgramStringN(prog, "exit")
While ProgramRunning(prog)
If AvailableProgramOutput(prog)
Answer$=ReadProgramString(prog)
If Answer$
Resultat$=resultat$+Answer$
EndIf
EndIf
Wend
CloseProgram(prog)
KillProgram(Prog)
EndIf
EndProcedure
Procedure Listpartition(Parameter)
prog = RunProgram("cmd.exe", "", "", #PB_Program_Open|#PB_Program_Read|#PB_Program_Write|#PB_Program_Hide)
If IsProgram(prog)
WriteProgramStringN(prog, "diskpart")
WriteProgramStringN(prog, "select disk "+Str(Parameter))
WriteProgramStringN(prog, "list partition")
WriteProgramStringN(prog, "exit")
WriteProgramStringN(prog, "exit")
While ProgramRunning(prog)
If AvailableProgramOutput(prog)
Answer$=ReadProgramString(prog)
If Answer$
Resultat$=resultat$+Answer$
EndIf
EndIf
Wend
CloseProgram(prog)
KillProgram(Prog)
EndIf
EndProcedure
Procedure ListVolume(Parameter)
prog = RunProgram("cmd.exe", "", "", #PB_Program_Open|#PB_Program_Read|#PB_Program_Write|#PB_Program_Hide)
If IsProgram(prog)
WriteProgramStringN(prog, "diskpart")
WriteProgramStringN(prog, "list volume")
WriteProgramStringN(prog, "exit")
WriteProgramStringN(prog, "exit")
While ProgramRunning(prog)
If AvailableProgramOutput(prog)
Answer$=ReadProgramString(prog)
If Answer$
Resultat$=resultat$+Answer$
EndIf
EndIf
Wend
CloseProgram(prog)
KillProgram(Prog)
EndIf
EndProcedure
Resultat$=""
CreateThread(@Listdisk(), 0)
Delay(500)
Debug Resultat$
disk$="Disque "; in french, so change it into your language !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ndisk=CountString(Resultat$,disk$)-1
Debug " count of Disks " + ndisk
For i=0 To ndisk-1
Resultat$=""
CreateThread(@Listpartition(), i)
Delay(500)
Debug Resultat$
partition$="Partition "; in french, so change it into your language !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
npartition=CountString(Resultat$,partition$)-1
Debug " count of partitions " + npartition
Next i
Resultat$=""
CreateThread(@ListVolume(), 0)
Delay(500)
Debug Resultat$
volume$="Volume "; in french, so change it into your language !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
nvolume=CountString(Resultat$,volume$)-1
Debug " count of volumes " + nvolume
In each 'Resultat$', you will find a lot of informations, and you can extract them with 'findstring()', ...
Mesa.