Results 1 to 5 of 5

Thread: How to choose which CD to play audio from.

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    England
    Posts
    6

    Cool

    Hi again ppl..

    (sorry for asking perhaps easy things, but I have no VB6EE references so I have to work from... Excel 2000 VB help.. which as u know is limited)

    Anyone know how I get a list of available CD drives, so that I can choose in program which cd I want to play audio from..
    say I have a small listbox (or something) with only cd/dvd drives listed.. i can then select the one corrosponding to the cd with the music track disc in... and then use the MMControl (which is already working thanks to .. some AllExperts Expert bloke!) to control it.

    Thanks!
    -------------
    Welcome to the Darkness

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    You can use the GetDriveType and GetLogicalDriveStrings API's, i.e.

    In a Module:
    Code:
    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
    
    Public Function FindCDROM(Optional ByVal bList As Boolean = False) As String
        Dim sDrives As String
        Dim sDrive As String
        Dim sList 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
                sList = sList & "," & sDrive
                If Not bList Then
                    FindCDROM = sDrive
                    Exit Function
                End If
            End If
            sDrives = Mid$(sDrives, Len(sDrive) + 2)
        Wend
        If Len(sList) Then FindCDROM = Mid(sList, 2)
    End Function
    Example:
    Code:
    Debug.Print "CDROM Drives - " & FindCDROM(True)

  3. #3
    Addicted Member
    Join Date
    Sep 2000
    Location
    Atlanta, GA
    Posts
    177
    This coding determines all drives on your system
    Option Explicit

    'GetDriveType return values
    Private Const DRIVE_REMOVABLE = 2
    Private Const DRIVE_FIXED = 3
    Private Const DRIVE_REMOTE = 4
    Private Const DRIVE_CDROM = 5
    Private Const DRIVE_RAMDISK = 6

    Private Declare Function SetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long

    Private Sub Form_Click()

    Dim i, Drv, D$
    For i = 0 to 25 'All possible drives A to Z
    D$ = Chr$(i + 65) & ":"
    Drv = GetDriveType(D$)
    Select Case Drv
    Case DRIVE_REMOVABLE
    Print "Drive " & D$ & " is removable."
    Case DRIVE_FIXED
    Print "Drive " & D$ & " is fixed."
    Case DRIVE_REMOTE
    Print "Drive " & D$ & " is remote."
    Case DRIVE_CDROM
    Print "Drive " & D$ & " is CD-ROM."
    Case DRIVE_RAMDISK
    Print "Drive " & D$ & " is RAM disk."
    Case Else
    End Select
    Next i
    End Sub

    This coding displays current drive:
    Dim CurDirectory$

    CurDirectory$ = CurDir

    This coding allows you to change directories (I may have implemented this section wrong but everything is here):
    Dim NewDirectory$

    'After you determine which CD-ROM you want set it to a variable
    NewDirectory$ = "<Place Drive Letter Here>"

    ChDir = NewDirectory$

    Let me know how the coding works. I hope I helped


    212 will lead you to the truth

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    England
    Posts
    6

    Cool Cheers

    Thanks to you both..
    I shall try it out, and see what I get!
    -------------
    Welcome to the Darkness

  5. #5
    Addicted Member
    Join Date
    Sep 2000
    Location
    Atlanta, GA
    Posts
    177

    Talking

    No Prob! Happy coding.
    212 will lead you to the truth

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