Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Function DriveExists(DriveLetter As String) As Boolean
Dim Buffer As String * 255
Dim BuffLen As Long
DLetter = Left(DriveLetter, 1)
BuffLen = GetLogicalDriveStrings(Len(Buffer), Buffer)
DriveExists = False
For i = 1 To BuffLen
If UCase(Mid(Buffer, i, 1)) = UCase(DLetter) Then
DriveExists = True
Exit Function
End If
Next i
End Function
Sub Main()
Debug.Print DriveExists("c:\")
End Sub
|