'on a module form
'use as:
'MsgBox GetAllDrives
'this will give you all the drives attached to your system

Declare Function GetLogicalDriveStrings Lib "kernel32" 

alias

"GetLogicalDriveStringsA" (ByVal nBufferLength

as

Long, ByVal lpBuffer

as

String)

as

Long Declare Function GetDriveType Lib "kernel32"

alias

"GetDriveTypeA" (ByVal nDrive

as

String)

as

Long Global Const DRIVE_REMOVABLE = 2 Global Const DRIVE_FIXED = 3 Global Const DRIVE_REMOTE = 4 Global Const DRIVE_CDROM = 5 Global Const DRIVE_RAMDISK = 6 Public Function GetAllDrives()

as

String Dim lngResult&, strDrives$, strJustOneDrive$, intPos%, lngDriveType& strDrives$ = Space$(255) lngResult& = GetLogicalDriveStrings(Len(strDrives$), strDrives$) strDrives$ = Left$(strDrives$, lngResult&) Do intPos% = InStr(strDrives$, Chr$(0)) If intPos% Then strJustOneDrive$ = Left$(strDrives$, intPos%) strDrives$ = Mid$(strDrives$, intPos% + 1, Len(strDrives$)) lngDriveType& = GetDriveType(strJustOneDrive$)

select

case

lngDriveType&

case

DRIVE_CDROM strBuffer = strBuffer & "CD-Rom: " & strJustOneDrive$ & vbCRLF

case

DRIVE_REMOVABLE strBuffer = strBuffer & "RemovableDrive: " & strJustOneDrive$ & vbCRLF

case

DRIVE_FIXED strBuffer = strBuffer & "LocalDrive: " & strJustOneDrive$ & vbCRLF

case

DRIVE_REMOTE strBuffer = strBuffer & "NetworkDrive: " & strJustOneDrive$ & vbCRLF

case

DRIVE_RAMDISK strBuffer = strBuffer & "RamDrive: " & strJustOneDrive$ & vbCRLF

end

Select

end

If

loop

Until strDrives$ = "" GetAllDrives = strBuffer End Function
Return