PRB: MCI Eject Button Fails to Close Caddyless CD-ROM Drive (116451)



The information in this article applies to:

  • Microsoft Visual Basic Professional Edition for Windows 3.0

This article was previously published under Q116451

SYMPTOMS

When you use the MultiMedia MCI custom control (MCI.VBX) to load a caddyless CD-ROM drive by clicking the eject button to close the drive, the drive will close and reopen instead of simply closing.

NOTE: A CD-ROM drive comes with either a caddy (a separate CD-ROM disk carrier that goes into a slot-like drive), or it comes with a built-in tray that opens (comes out of the drive) when you push a button. Those that have a built-in tray are known as caddyless CD-ROM drives.

CAUSE

There is a communication problem between the driver for the caddyless CD-ROM drive and the MultiMedia MCI custom control. This problem does not occur with all caddyless CD-ROM drives.

WORKAROUND

Obtain an updated driver that fixes this problem for the affected caddyless CD-ROM drive or use the following code, which works correctly with any CD-ROM drive:

  1. Start a new project in Visual Basic. Form1 is created by default.
  2. From the File menu, choose Add File. In the Add File dialog box, select the MCI.VBX custom control file, which is usually located in the \WINDOWS\SYSTEM directory.
  3. Add the MultiMedia MCI control (MMControl1) and two Command Button controls (Command1 and Command2) to Form1.
  4. Set the following properties for the three controls at design time:
       Control     Property      Setting
       ---------------------------------
       Command1    Caption       Init CD
       Command2    Caption       Eject
       MMControl1  EjectVisible  False
    						
  5. Place the following code in the (general) (declarations) section of Form1:
       ' Place the following Declare statement on one, single line:
       Declare Function mciSendString Lib "MMSystem.DLL"
          (ByVal lpstrCommand As String, ByVal lpstrReturnString As Any,
          ByVal wReturnLength As Integer, ByVal hCallback As Integer) As Long
    
       Dim Ejected As Integer
    						
  6. Add the following code to the Command1_Click event:
       Sub Command1_Click ()
          MMControl1.UpdateInterval = 0
          MMControl1.DeviceType = "CDAudio"
          MMControl1.Command = "Open"
          Ejected = False
          Command1.Enabled = False
          Command2.Enabled = True
       End Sub
    						
  7. Add the following code to the Command2_Click event:
       Sub Command2_Click ()
          Dim Status As Integer
          If Ejected Then
             Status = mciSendString("Set CDAudio Door Closed Wait", 0&, 0, 0)
             Ejected = False
             Command2.Caption = "Eject CD"
          Else
             Status = mciSendString("Set CDAudio Door Open Wait", 0&, 0, 0)
             If (Status <> 0) Then
                Command1.Enabled = True
                Command2.Enabled = False
                MMControl1.Command = "Close"
             End If
             Ejected = True
             Command2.Caption = "Load CD"
          End If
       End Sub
    						
  8. Open the caddyless CD-ROM drive manually, insert a CD-ROM disk and close the drive. Run the application. Click the Init CD button to enable the controls. Click the Eject button to eject the CD-ROM, and click the Load CD button to load the CD-ROM. Click the buttons on the MultiMedia MCI custom control itself to play the CD-ROM.

STATUS

Based on a number of tests, Microsoft has determined that this behavior occurs only on some caddyless CD-ROM drives. We are researching this behavior further and will post more information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps that Reproduce Behavior on Affected Caddyless CD-ROM Drives

  1. Start a new project in Visual Basic. Form1 is created by default.
  2. From the File menu, choose Add File. In the Add File dialog box, select the MCI.VBX custom control file, which is usually located in the \WINDOWS\SYSTEM directory.
  3. Add a MultiMedia MCI control (MMControl1) and a command button (Command1) to Form1.
  4. Set the Caption property of Command1 to Init CD.
  5. Add the following code to the Command1_Click event:
       Sub Command1_Click ()
          MMControl1.UpdateInterval = 0
          MMControl1.DeviceType = "CDAudio"
          MMControl1.Command = "Open"
       End Sub
    						
  6. Open the caddyless CD-ROM drive manually, insert a CD-ROM, and close the drive. Run the application. Click the Init CD button to enable the MultiMedia MCI custom control. Click the eject button to see the door of the caddyless CD-ROM drive open. Click the eject button again. The door of the caddyless CD-ROM drive closes and reopens, which disables the eject button.

Modification Type:MinorLast Reviewed:1/9/2003
Keywords:kbprb KB116451