GetLogicalDisk




Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias _
"GetLogicalDriveStringsA" (ByVal nBufferLength As Long, _
ByVal lpBuffer As String) As Long

' Check whether a given drive exist

' Note that this returns True even if the drive isn't currently ready

' (e.g. a diskette isn't in drive A:)


Function DriveExists(ByVal sDrive As String) As Boolean
Dim buffer As String
buffer = Space(64)
' return False if invalid argument

If Len(sDrive) = 0 Then Exit Function
'get the string that contains all drives

GetLogicalDriveStrings Len(buffer), buffer
' check that the letter we're looking for is there

DriveExists = InStr(1, buffer, Left$(sDrive, 1), vbTextCompare)
End Function











( getlogicaldisk.html )- by Paolo Puglisi - Modifica del 17/12/2023