
first available drive letter?
Quote:
>I'm using VB 5, and I would like to know how to find the first available
>drive letter. I've searched the API, and haven't found anything. For now,
>I'm making do by going through all drive letters and checking if the drive
>exists..
The GetLogicalDriveStrings API returns a string which is an ASCII 0 separated
list of all valid drive letters found on the system.
Put the following declarations in the General Declarations section of a form:
Private Declare Function GetLogicalDriveStrings Lib _
"kernel32" Alias "GetLogicalDriveStringsA" _
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Use this code to get the first valid drive:
Dim lLength As Long, lRet As Long
Dim sBuffer As String, sDrive As String
Dim iPos As Integer
sBuffer = Space$(2048)
lLength = 2047
lRet = GetLogicalDriveStrings(lLength, sBuffer)
iPos = InStr(sBuffer, Chr$(0))
sDrive = Left$(sBuffer, iPos - 1)
Lee Weiner
weiner AT fuse DOT net