CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2000
    Posts
    1

    access files on unknown CD drive

    I have a form with 3 buttons that access files on a cd. How do I read files from the cd? Keep in mind I don't know what drive letter the user has assigned to the cd drive and they could have more then one. Hope that makes sense.


  2. #2
    Join Date
    Sep 1999
    Location
    Red Wing, MN USA
    Posts
    312

    Re: access files on unknown CD drive

    You can use a Couple of APIs to determine which Drive is the CDROM, ie.

    private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (byval nDrive as string) as Long
    private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (byval nBufferLength as Long, byval lpBuffer as string) as Long
    private Const DRIVE_CDROM = 5

    Function FindCDROM() as string
    Dim sDrives as string
    Dim sDrive as string

    sDrives = Space(255)
    sDrives = Left$(sDrives, GetLogicalDriveStrings(255, byval sDrives))
    While InStr(sDrives, "\")
    sDrive = Left$(sDrives, InStr(sDrives, "\"))
    If GetDriveType(sDrive) = DRIVE_CDROM then
    FindCDROM = sDrive
    Exit Function
    End If
    sDrives = mid$(sDrives, len(sDrive) + 2)
    Wend
    End Function

    private Sub Command1_Click()
    Debug.print "CDROM is on Drive - " & FindCDROM
    End Sub





    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]
    Aaron Young
    Senior Programmer Analyst (Red Wing Software)
    Certified AllExperts Expert

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

Featured