|
|
Title | List information on the system's drives |
Keywords | drives, disks, information |
Categories | API, Windows |
|
|
Use the GetLogicalDriveStrings API function to get the drive names. Use the GetDriveType function to see what kinds of drives they are.
|
|
' Return an array of drive names.
Public Function GetDriveNames() As String()
Dim all_drives As String
Dim len_drives As Long
Dim drive_array() As String
' See how long the drive buffer needs to be.
len_drives = GetLogicalDriveStrings(0, all_drives)
all_drives = Space$(len_drives)
' Get the drive information.
If GetLogicalDriveStrings(len_drives, all_drives) <> 0 _
Then
drive_array = Split(all_drives, Chr$(0))
' Remove the last two blank entries.
ReDim Preserve drive_array(0 To UBound(drive_array) _
- 2)
GetDriveNames = drive_array
End If
End Function
Private Sub ListDrives()
Dim drives() As String
Dim i As Integer
Dim drive_info As String
' Get all the drive names.
drives = GetDriveNames()
For i = LBound(drives) To UBound(drives)
Select Case GetDriveType(drives(i))
Case DRIVE_REMOVABLE
drive_info = drives(i) & vbTab & "Removable"
Case DRIVE_FIXED
drive_info = drives(i) & vbTab & "Fixed"
Case DRIVE_REMOTE
drive_info = drives(i) & vbTab & "Remote"
Case DRIVE_CDROM
drive_info = drives(i) & vbTab & "CDROM"
Case DRIVE_RAMDISK
drive_info = drives(i) & vbTab & "RAM Disk"
End Select
List1.AddItem drive_info
Next i
End Sub
|
|
|
|
|
|