• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Masaüstü öğelerini, listbox da gösterme

Katılım
16 Eylül 2005
Mesajlar
179
Excel Vers. ve Dili
Excel 2007 12.0
Selam arkadaşlar, aşağıdaki kodlarla Bilgisayarım daki öğeleri (drives) listeliyorum.

Kod:
    Set FS = CreateObject("Scripting.FileSystemObject") 'drive list
    Set DC = FS.Drives
    x = 0
    t=""
    For Each D In DC
        If D.DriveType = Remote Then
            N = D.ShareName
        Else
            N = D.VolumeName
        End If
            Select Case D.DriveType
                Case 0: t = "Unknown"
                Case 1: t = "Removable"
                Case 2: t = "Fixed"
                Case 3: t = "Network"
                Case 4: t = "CD-ROM"
                Case 5: t = "RAM Disk"
            End Select
        ListBox2.AddItem
        ListBox2.List(x, 0) = N & " (" & D.DriveLetter & ":)"
        ListBox2.List(x, 1) = "GB " & Format(D.TotalSize / 1024 / 1024 / 1024, "#,##0.00")
        ListBox2.List(x, 2) = "GB " & Format(D.AvailableSpace / 1024 / 1024 / 1024, "#,##0.00")
        ListBox2.List(x, 3) = t
        ListBox2.List(x, 4) = D.FileSystem
        x = x + 1
    Next
benzer şekilde Desktop ta yer alan bilgisayarım, ağ bağlantılarım, geri dönüşüm kutusu, belgelerim ve diğer dosya ve klasörleri nasıl listeleyebilir?

"C:\Documents and Settings\All Users\Desktop\" dizinini çektiğimde klasör veya dosyaları rahatlıkla alabiliyorum ancak diğerlerini nasıl alırız; bu konuda yardımcı olur musunuz?
(herhangi bir klasörü aşağıdaki kodlarla listeleyebiliyorum.)

Kod:
PathX="c:\"
    ListBox3.Clear
    ListBox5.Clear
    Set Klasör = FS.GetFolder(PathX)
    Set Klasörler = Klasör.SubFolders
    Label13.Width = 2
    x = 0
    For Each KlasörX In Klasörler
    Label13.Width = Label13.Width + Label12.Width / Klasör.SubFolders.Count
    With ListBox3
    .AddItem
    .List(x, 0) = KlasörX.Name
    If CheckBox2.Value = True Then .List(x, 1) = KlasörX.Type
    If CheckBox1.Value = True Then
        BOYUT = KlasörX.Size
                If Err.Number <> 0 Then
                MsgBox "'" & Dosya.Name & "' klasörüne erişim izniniz yok.", vbOKOnly + vbExclamation, "Uyarı"
                'Exit Sub
                Err.Number = 0
                End If
          .List(x, 2) = "hesaplıyor..."
            .ListIndex = .ListCount - 1
            DoEvents
            If .List(x, 2) = "hesaplıyor..." Or .List(x, 2) = "" Then .List(x, 2) = "-"
            If BOYUT <= 1024 Then
                .List(x, 2) = " B " & Format(BOYUT, "#,##0.00")
            ElseIf BOYUT <= (1048576) Then
                .List(x, 2) = "KB " & Format(BOYUT / 1024, "#,##0.00")
            ElseIf BOYUT <= 1073741824 Then
                .List(x, 2) = "MB " & Format(BOYUT / 1024 / 1024, "#,##0.00")
            ElseIf BOYUT > 1073741824 Then
                .List(x, 2) = "GB " & Format(BOYUT / 1024 / 1024 / 1024, "#,##0.00")
            End If
    End If
        Set AltKlasör = FS.GetFolder(PathX & KlasörX.Name)
        .List(x, 3) = AltKlasör.SubFolders.Count & " Klasör - " & AltKlasör.Files.Count & " Dosya"
        ListBox5.AddItem AltKlasör.Name
        Set AltKlasör = Nothing
        If CheckBox2.Value = True Then .List(x, 4) = Format(KlasörX.DateCreated, "mm.dd.yyyy hh:mm:ss")
    End With
    x = x + 1
    Next
 
Üst