Help me load the Index Number of Drives (the Uninitialized and Initialized Drives)

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
hoangdiemtinh
Messages : 2
Inscription : mer. 16/nov./2022 14:01

Help me load the Index Number of Drives (the Uninitialized and Initialized Drives)

Message par hoangdiemtinh »

Hi admin,

I am newbie, from Viet Nam. Sorry for my bad English.

I am trying load information of Drives (Index + Name + Total Size + Total Partitions) to the ComboBox Gadget, like the picture
.
Image
.
(HD = Hard Disk, RM = Removable = USB FLash, Card Reader)
.
An Uninitialized Drive is no have Letter Drive. Only can get information its via the Index Number of it.
.
Someone please help me (Prefer WinAPI, then maybe WMI).

Thanks.
Avatar de l’utilisateur
Mindphazer
Messages : 694
Inscription : mer. 24/août/2005 10:42

Re: Help me load the Index Number of Drives (the Uninitialized and Initialized Drives)

Message par Mindphazer »

Tiens, un bot intelligent...
Bureau : Win10 64bits
Maison : Macbook Pro M3 16" SSD 512 Go / Ram 24 Go - iPad Pro 32 Go (pour madame) - iPhone 15 Pro Max 256 Go
Avatar de l’utilisateur
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

Re: Help me load the Index Number of Drives (the Uninitialized and Initialized Drives)

Message par Ar-S »

ça ressemble pas à un bot..
Please hoangdiemtinh could you juste write in english the color of that word. Thanks
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
hoangdiemtinh
Messages : 2
Inscription : mer. 16/nov./2022 14:01

Re: Help me load the Index Number of Drives (the Uninitialized and Initialized Drives)

Message par hoangdiemtinh »

@Ar-S
that word

I am new member, not ROBOT or BOT.
Sorry, my English is not good. I am using google translator.
Avatar de l’utilisateur
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

Re: Help me load the Index Number of Drives (the Uninitialized and Initialized Drives)

Message par Ar-S »

Thank you and welcome.
Could you please try to write here your text in french here instead of english. Thanks.

You can use that API to show the drive information.
Tu peux utiliser cet API pour connaître les infos de tes lecteurs

I don't know how to detect disk partitioning.

Je ne sais pas comment détecter le partitionnement des disques.

Code : Tout sélectionner

EnableExplicit

Define lpFreeBytesAvailable.q
Define lpTotalNumberOfBytes.q
Define lpTotalNumberOfFreeBytes.q

GetDiskFreeSpaceEx_("C:\", @lpFreeBytesAvailable, @lpTotalNumberOfBytes, @lpTotalNumberOfFreeBytes)

Debug "Free space: " + Str(lpFreeBytesAvailable/1024/1024/1024) + " GB"
Debug "Used space: " + Str((lpTotalNumberOfBytes-lpFreeBytesAvailable)/1024/1024/1024) + " GB"
Debug "total: " + Str(lpTotalNumberOfBytes/1024/1024/1024) + " GB"
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Mesa
Messages : 1126
Inscription : mer. 14/sept./2011 16:59

Re: Help me load the Index Number of Drives (the Uninitialized and Initialized Drives)

Message par Mesa »

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.
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Re: Help me load the Index Number of Drives (the Uninitialized and Initialized Drives)

Message par Ollivier »

Répondre