Results 1 to 4 of 4

Thread: Eject CD-Rom problem using VB code

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Location
    Cambridge,Canada
    Posts
    2

    Post

    I wrote a program to eject CD-Rom using mci controls. Only work if, I have a CD inside the CD-Rom. Is anyone know how to eject CD-Rom without any CD inside.

    Thanks

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

    Post

    This always works for me:

    Code:
    Private 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
    
    '-------Put this on any event
    Call mciSendString("Set CDAudio Door open Wait", 0&, 0&, 0&)
    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


  3. #3
    Guest

    Post

    wow, i would have expected shedloads of code!
    Serge, do you know how to ask the drive whether it is open already, and if so, how to close it?

    ------------------

    Wossname,
    Email me: [email protected]

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Use DOOR CLOSED in the Command String, if it's not Open it just won't do anything, eg.
    Code:
    Private 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
    
    Private Sub Command1_Click()
        Static bOpen As Boolean
        If Not bOpen Then
            Call mciSendString("SET cdaudio DOOR OPEN wait", "", 0, 0)
        Else
            Call mciSendString("SET cdaudio DOOR CLOSED wait", "", 0, 0)
        End If
        bOpen = Not bOpen
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

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