Results 1 to 2 of 2

Thread: getting drive letters

  1. #1
    Guest
    How does one obtain the CD Drive letter of a user's machine?

    What are the commands for accessing the Registry? Are these done only with WinAPI?

    Thanks.

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Lightbulb

    Try something like this:
    Code:
    Option Explicit
    Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
    
    Private Sub Form_Load()
        Dim lngRet As Long
        Dim strBuffer As String
        Dim intPost As Integer
        Dim strDrive As String
        
        strBuffer = Space(255)
        lngRet = GetLogicalDriveStrings(Len(strBuffer), strBuffer)
        
        intPost = InStr(strBuffer, vbNullChar)
        strDrive = Left(strBuffer, intPost - 1)
        List1.AddItem strDrive
        
        Do Until intPost = 0
            strDrive = Mid(strBuffer, intPost + 1, 3)
            List1.AddItem strDrive
            intPost = InStr(intPost + 1, strBuffer, vbNullChar)
        Loop
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width