Use the GetLogicalDriveStrings API, i.e.
In a Module:
Code:
Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Public Function GetDrives() As Variant
Dim sDrive() As String
Dim sDrives As String
Dim nDrives As Long
sDrives = Space(255)
sDrives = Left(sDrives, GetLogicalDriveStrings(255, sDrives))
While Len(sDrives)
ReDim Preserve sDrive(nDrives)
sDrive(nDrives) = Left(sDrives, 3)
nDrives = nDrives + 1
sDrives = Mid(sDrives, 5)
Wend
GetDrives = sDrive
End Function
Example usage:
Code:
Private Sub Command1_Click()
Dim vDrives As Variant
Dim nDrive As Long
vDrives = GetDrives
For nDrive = 0 To UBound(vDrives)
List1.AddItem vDrives(nDrive)
Next
End Sub