first available drive letter? 
Author Message
 first available drive letter?

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..

Thanks

Brian



Wed, 27 Dec 2000 03:00:00 GMT  
 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



Thu, 28 Dec 2000 03:00:00 GMT  
 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..

I think that's the best solution... It's safe, if you use an API call
like GetDriveType(), which will return -1 if the drive doesn't exist.

HTH,
Bart.



Thu, 28 Dec 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Finding next available drive letter

2. logon script to check the next available drive letter (The code is a bit long)

3. next available drive letter

4. Drive letter driving me crazy!

5. Retrieving drive letter for user's cd-rom drive

6. Determining drive letter assigned to floppy drive?

7. local drive letter <> drive share name

8. Searching for records on only first three letters - Repost

9. How to make the first letters uppercase ?

10. Capitalizing The First Letter Of Each Word

11. How to make first letter of textbox appear only

12. Heading to show first letter of surnames on page

 

 
Powered by phpBB® Forum Software