you need one button on a form called cmdGetDrives
then paste this code into the form
Code:
Option Explicit
Option Base 0
Private Declare Function GetDriveType Lib "KERNEL32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Declare Function GetLogicalDrives Lib "KERNEL32" () As Long
Private Const DR_REMOVABLE = 2
Private Const DR_FIXED = 3
Private Const DR_REMOTE = 4
Private Const DR_CDROM = 5
Private Const DR_RAMDISK = 6
Private Sub cmdGetDrives_Click()
Dim aDriveInfo() As String
Dim i&
aDriveInfo = DrivesAndTypes
For i = LBound(aDriveInfo) To UBound(aDriveInfo)
Debug.Print aDriveInfo(i)
Next i
End Sub
Public Function MakeDriveLetter(sDrive$) As String
MakeDriveLetter = CStr(sDrive) & ":\"
Exit Function
End Function
Public Function DrivesAndTypes() As String()
Dim LDs&, Cnt&, sDrives$, sCurrentDrive$
Dim aHolder() As String
LDs = GetLogicalDrives
For Cnt = 0 To 25
If (LDs And 2 ^ Cnt) <> 0 Then
ReDim Preserve aHolder(Cnt)
sCurrentDrive = MakeDriveLetter(Chr$(65 + Cnt))
Select Case GetDriveType(sCurrentDrive)
Case DR_REMOVABLE
aHolder(Cnt) = sCurrentDrive & " Is Removable"
Case DR_FIXED
aHolder(Cnt) = sCurrentDrive & " Is Fixed"
Case Is = DR_REMOTE
aHolder(Cnt) = sCurrentDrive & " Is Remote"
Case Is = DR_CDROM
aHolder(Cnt) = sCurrentDrive & " Is a CD Drive"
Case Is = DR_RAMDISK
aHolder(Cnt) = sCurrentDrive & " Is a RAM Disk"
Case Else
aHolder(Cnt) = sCurrentDrive & " Is Unknown"
End Select
End If
Next Cnt
DrivesAndTypes = aHolder
End Function