FileSystemObjectオブジェクト - Drivesプロパティ





【書式】
FileSystemObject.Drives

システムで使用できる、全てのDriveオブジェクトの集合体であるDrivesコレクションを返します。
Sub test1()
    ''全てのドライブ名を表示します
    Dim FSO As Object, Drv As Variant, buf As String
    Set FSO = CreateObject("Scripting.FileSystemObject")
    For Each Drv In FSO.Drives
        buf = buf & Drv.DriveLetter & vbCrLf
    Next Drv
    MsgBox buf & "が接続されています"
    Set FSO = Nothing
End Sub