Code : Tout sélectionner
#include <GUIConstantsEx.au3>
;#include <Array.au3>
#include <ListviewConstants.au3>
SplashTextOn ("", "Loading...", 180, 60, -1, -1, 49)
Global $var = DriveGetDrive("FIXED")
$myinfos = _GetDriveInfos()
;_arraydisplay($myinfos)
$W = 610
$Ypos = 45+(14*$var[0])
$Main = GuiCreate("Disques", $W+260, $Ypos)
$listview = GUICtrlCreateListView("Volume|Nom|Taille (Go)|Disponible (Go)|Occupé (Go)|" & _
"Plein à|Libre (Go)|Disque physique|ID", 10, 5, $W+240, $Ypos-15)
For $i = 0 to $var[0]-1
$percentocc = Round(($myinfos[$i][2]-$myinfos[$i][3])*100/$myinfos[$i][2], 1)
GUICtrlCreateListViewItem(StringUpper($myinfos[$i][0]) &"|"& $myinfos[$i][6] &"|"& _
$myinfos[$i][4] &"|"& $myinfos[$i][2] &"|"& $myinfos[$i][2]-$myinfos[$i][3] &"|"& _
$percentocc &" %" &"|"& $myinfos[$i][3] &"|"& $myinfos[$i][1] &"|"& $myinfos[$i][5], $listview)
Next
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 0, 60)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 1, 110)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 2, 70)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 3, 90)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 4, 80)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 5, 70)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 6, 70)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 7, 170)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 8, 120)
GUISetState()
SplashOff()
While GUIGetMsg()<>$GUI_EVENT_CLOSE
Sleep(10)
WEnd
;======================================
Func _GetDriveInfos()
Dim $specifs[$var[0]][7]
For $i = 1 to $var[0]
Dim $Services = ObjGet('winmgmts:\\.\root\cimv2')
Dim $DiskDrives = $Services.ExecQuery("Select Caption, DeviceID From Win32_DiskDrive")
For $DiskDrive In $DiskDrives
Dim $DiskPartitions = $Services.ExecQuery("Associators of {Win32_DiskDrive.DeviceID='" & _
$DiskDrive.DeviceID & "'} Where AssocClass = Win32_DiskDriveToDiskPartition")
For $DiskPartition In $DiskPartitions
Dim $LogicalDisks = $Services.ExecQuery ("Associators of {Win32_DiskPartition.DeviceID='" & _
$DiskPartition.DeviceID & "'} Where AssocClass = Win32_LogicalDiskToPartition")
For $LogicalDisk In $LogicalDisks
If $LogicalDisk.DeviceID = $var[$i] Then
$specifs[$i-1][0] = $var[$i]
$specifs[$i-1][1] = $DiskDrive.Caption
$specifs[$i-1][2] = Round(DriveSpaceTotal($var[$i])/1000 )
$specifs[$i-1][3] = Round(DriveSpaceFree($var[$i])/1000 )
$specifs[$i-1][4] = Round($LogicalDisk.Size/1000000000)
$specifs[$i-1][5] = $DiskPartition.DeviceID
$specifs[$i-1][6] = $LogicalDisk.VolumeName
EndIf
Next
Next
Next
Next
Return $specifs
EndFunc