VB Code:
Private Declare Function GetLogicalDrives Lib "kernel32" () As Long
Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Sub Form_Paint()
Dim DriveData As Long, i As Long, strDrives As String
'get the available drives
DriveData = GetLogicalDrives
strDrives = "Available drives:"
For i = 0 To 25
If (DriveData And 2 ^ i) <> 0 Then
strDrives = strDrives + " " + Chr$(65 + i)
End If
Next i
MsgBox strDrives 'display drives
Dim strSave As String
Me.AutoRedraw = True
strSave = String(255, Chr$(0))
ret& = GetLogicalDriveStrings(255, strSave)
For keer = 1 To 100
If Left$(strSave, InStr(1, strSave, Chr$(0))) = Chr$(0) Then Exit For
Me.Print Left$(strSave, InStr(1, strSave, Chr$(0)) - 1) 'print drives
strSave = Right$(strSave, Len(strSave) - InStr(1, strSave, Chr$(0)))
Next keer
End Sub