#include <GUIConstants.au3> #include <File.au3> Opt("GUIOnEventMode", 1) $Gui = GUICreate("TreeView", 400, 400) $treeview = GUICtrlCreateTreeView(20, 20, 200, 200, -1, $WS_EX_CLIENTEDGE) Root($treeview) GUISetOnEvent($GUI_EVENT_CLOSE, "_close") GUISetState(@SW_SHOW) While 1 Sleep(500) WEnd Func TellMe() MsgBox(0,'', GUICtrlRead(@GUI_CtrlId, 1)) EndFunc Func Root($tvcID) Dim $DGD = DriveGetDrive("ALL") For $i = 1 To $DGD[0] GUICtrlCreateTreeViewItem("(" & $DGD[$i] & ")", $tvcID) GUICtrlSetState(-1, $GUI_FOCUS) GUICtrlSetOnEvent(-1, "TellMe") GUICtrlSetImage(-1, "shell32.dll", FindIcon($DGD[$i]), 2) GUICtrlSetImage(-1, "shell32.dll", FindIcon($DGD[$i]), 4) If $DGD[$i] = @HomeDrive Then $FL2A = _FileListToArray($DGD[$i], "*", 2) For $j = 1 To $FL2A[0] GUICtrlCreateTreeViewItem($FL2A[$j], GUICtrlRead($tvcID)) GUICtrlSetImage(-1, "shell32.dll", -5, 2) GUICtrlSetImage(-1, "shell32.dll", -4, 4) GUICtrlSetOnEvent(-1, "TellMe") Next EndIf Next EndFunc Func FindIcon($dI) Local $DGT = DriveGetType($dI) Switch $DGT Case "Removable" If $dI = "a:" Or $dI = "b:" Then Return -7 Else Return -8 EndIf Case "Fixed" Return -9 Case "Network" If DriveMapGet($dI) <> "" Then Return -10 Else Return -11 EndIf Case "CDROM" Return -12 Case "RAMDisk" Return -13 Case "Unknown" Return -54 EndSwitch EndFunc Func _close() Exit EndFunc |