'on a module form 'use as: 'MsgBox GetAllDrives 'this will give you all the drives attached to your system Declare Function GetLogicalDriveStrings Lib "kernel32"Returnalias
"GetLogicalDriveStringsA" (ByVal nBufferLengthas
Long, ByVal lpBufferas
String)as
Long Declare Function GetDriveType Lib "kernel32"alias
"GetDriveTypeA" (ByVal nDriveas
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$ & vbCRLFcase
DRIVE_REMOVABLE strBuffer = strBuffer & "RemovableDrive: " & strJustOneDrive$ & vbCRLFcase
DRIVE_FIXED strBuffer = strBuffer & "LocalDrive: " & strJustOneDrive$ & vbCRLFcase
DRIVE_REMOTE strBuffer = strBuffer & "NetworkDrive: " & strJustOneDrive$ & vbCRLFcase
DRIVE_RAMDISK strBuffer = strBuffer & "RamDrive: " & strJustOneDrive$ & vbCRLFend
Selectend
Ifloop
Until strDrives$ = "" GetAllDrives = strBuffer End Function