Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPublic dates As Date Private Declare Function ExtractAssociatedIcon Lib "shell32.dll" Alias "ExtractAssociatedIconA" (ByVal hInst As Long, ByVal lpIconPath As String, lpiIcon As Long) As Long Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long Private Sub Form_Load() Dim cpt1 As Integer Dim mIcon As Long Dim repertoire As String Dim fichier As String Dim taille As String Dim tabl() As String Dim obj As ListItem view.ColumnHeaders.Clear view.ListItems.Clear view.ColumnHeaders.Add , , "icon", view.Width / 4 view.ColumnHeaders.Add , , "fichier", view.Width / 4 view.ColumnHeaders.Add , , "taille", view.Width / 4 - 65 view.ColumnHeaders.Add , , "date de creation", view.Width / 4 view.HideColumnHeaders = False view.view = lvwReport repertoire = InputBox("ne pas oublier le \ a la fin", "arbrescense du fichier") fichier = Dir(repertoire & "\*.*") While fichier <> "" mIcon = ExtractAssociatedIcon(App.hInstance, repertoire & fichier, 2) DrawIcon Image.hdc, cpt1, 0, mIcon DestroyIcon mIcon taille = FileLen(repertoire & fichier) If taille > 1024 Then taille = taille / 1024 tabl = Split(taille, ",") taille = tabl(0) If taille > 1024 Then taille = taille / 1024 tabl = Split(taille, ",") taille = tabl(0) & " Mo" Else taille = taille & " Ko" End If Else taille = taille & " o" End If cpt1 = cpt1 + 40 GetDates (repertoire & fichier) Set obj = view.ListItems.Add(, , fichier) obj.SubItems(1) = fichier obj.SubItems(2) = taille obj.SubItems(3) = dates fichier = Dir() Wend End Sub Private Sub GetDates(strFile As String) Dim st(0 To 2) As SYSTEMTIME, I As Byte If GetFileTimes(strFile, st(0), st(1), st(2)) Then dates = CStr(st(I).wDay) & "/" & CStr(st(I).wMonth) & "/" & CStr(st(I).wYear) End If End Sub
Private Declare Function ExtractAssociatedIcon Lib "shell32.dll" Alias "ExtractAssociatedIconA" (ByVal hInst As Long, ByVal lpIconPath As String, lpiIcon As Long) As Long Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long Private Sub Form_Load() Dim mIcon As Long Dim repertoire As String Dim fichier As String View.ColumnHeaders.Clear View.ListItems.Clear View.ColumnHeaders.Add , , "Fichier", View.Width View.HideColumnHeaders = False View.View = lvwReport repertoire = "C:" fichier = Dir(repertoire & "\*.*") ImageList1.ImageHeight = 20 ImageList1.ImageWidth = 24 PicIcon.BackColor = vbWhite PicIcon.AutoRedraw = True While fichier <> "" mIcon = ExtractAssociatedIcon(App.hInstance, repertoire & fichier, 2) PicIcon.Cls DrawIcon PicIcon.hdc, 0, 0, mIcon DestroyIcon mIcon ImageList1.ListImages.Add Key:=fichier, Picture:=PicIcon.Image View.ListItems.Add Key:=fichier, Text:=fichier fichier = Dir() Wend Dim LI As ListItem Set View.SmallIcons = ImageList1 For Each LI In View.ListItems LI.SmallIcon = LI.Text Next LI End Sub