">

怎样得到一个系统盘的全名,不是字符,是全名,如:本地磁盘(C:)

80酷酷网    80kuku.com

Private Sub Command1_Click()
    Dim ShellApp, oPanel, FolderItem1, FolderItem2, oItem
    Set ShellApp = CreateObject("Shell.Application")
    Set oPanel = ShellApp.NameSpace(0)

    Set FolderItem2 = Nothing
    For Each FolderItem1 In oPanel.Items
      If FolderItem1.Name = "我的电脑" Then
        Set FolderItem2 = FolderItem1.Getfolder: Exit For
      End If
        Debug.Print FolderItem1.Name
    Next

    If FolderItem2 Is Nothing Then
      MsgBox "找不到项目!"
      Exit Sub
    End If

    Set oItem = Nothing
    For Each oItem In FolderItem2.Items
        Debug.Print oItem.Name
    Next
End Sub



输出结果如下:

控制面板3.5 软盘 (A:)WINDOWS98 (C:)程序 (D:)本地磁盘 (E:)数据备份 (F:)光盘 (G:)

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: