DriveExists – Check whether a logical drive exists

DriveExists – Check whether a logical drive exists

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

See also  Why ChatGPT Is So Important Today

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist