Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Jan 15, 2000

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

Marco Bellinaso
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date