Results 1 to 4 of 4

Thread: A twist on CD eject

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    2

    Question

    How could I alter the code for ejecting a CD-ROM so that, on a PC with multiple CD-ROM drives, the drive that ejects is always the one containing the CD with my app on it? Could I use app.Path somehow?

    Thanks

  2. #2
    New Member
    Join Date
    Jun 2000
    Location
    Canada
    Posts
    8

    Question What Is The Code?

    I've never seen the code used to open a Cd-ROm drive. Does it contain a drive letter or is it just sort of generic? If it has a drive letter, and the program runs, or accesses files from the cd then app.path might work! Can you post the actual code to open the CD??
    thanx
    Jonathan (Co President - Big Berdie International)
    Karl Moore RULEZ!
    "Pipers Do It With Amazing Grace!"

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    big-berdie

    'open and close the cd door'

    Option Explicit

    Declare Function mciSendString Lib "winmm.dll" Alias _
    "mciSendStringA" (ByVal lpstrCommand As String, ByVal _
    lpstrReturnString As String, ByVal uReturnLength As Long, _
    ByVal hwndCallback As Long) As Long

    '===============================================================

    'To open the CD door, use this code:

    retvalue = mcisendstring("set CDAudio door open", _
    returnstring, 127, 0)

    'To close the CD door, use this code:

    retvalue = mcisendstring("set CDAudio door closed", _
    returnstring, 127, 0)

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4
    Guest
    This code, I believe finds all CD letters.

    Code:
    Const DRIVE_CDROM = 5
    
    Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
    Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
    
    Private Sub Command1_Click()
    Dim tmp As Integer
    Dim tmpStr As String
    Dim Drives As String
    Dim CDsCount As Integer
    Dim CDsLetters As String
    
    'init Drives to 255 spaces
    Drives = Space(255)
    'get drives, Drives var will look like
    '   A:\<NULL>C:\<NULL>D:\<NULL>E:\<NULL><NULL>
    'ret& is the new length of Drives
    ret& = GetLogicalDriveStrings(Len(Drives), Drives)
    For tmp = 1 To ret& Step 4
     'get a drive root directory (like "C:\")
     tmpStr = Mid(Drives, tmp, 3)
     'if drive is a CD
     If GetDriveType(tmpStr) = DRIVE_CDROM Then
      CDsCount = CDsCount + 1
      CDsLetters = CDsLetters & Left(tmpStr, 1) & " "
     End If
    Next tmp
    'display results
    If CDsCount Then
     MsgBox "Number of CDs Available: " & CDsCount & " - CDs Letters: " & UCase(CDsLetters)
    Else
     MsgBox "No CDs Available"
    End If
    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