Microsoft KB Archive/116451

= PRB: MCI Eject Button Fails to Close Caddyless CD-ROM Drive =

Article ID: 116451

Article Last Modified on 1/9/2003

-

APPLIES TO


 * Microsoft Visual Basic 3.0 Professional Edition

-



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:

 Start a new project in Visual Basic. Form1 is created by default. 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. Add the MultiMedia MCI control (MMControl1) and two Command Button controls (Command1 and Command2) to Form1.  Set the following properties for the three controls at design time:   Control     Property      Setting -  Command1    Caption       Init CD   Command2    Caption       Eject MMControl1 EjectVisible  False   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   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 </li>  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 </li> 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.</li></ol>

<div class="status_section">

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.

<div class="moreinformation_section">

Steps that Reproduce Behavior on Affected Caddyless CD-ROM Drives
<ol> Start a new project in Visual Basic. Form1 is created by default.</li> 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.</li> Add a MultiMedia MCI control (MMControl1) and a command button (Command1) to Form1.</li> Set the Caption property of Command1 to Init CD.</li>  Add the following code to the Command1_Click event: Sub Command1_Click MMControl1.UpdateInterval = 0 MMControl1.DeviceType = "CDAudio" MMControl1.Command = "Open" End Sub </li> 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.</li></ol>

Additional query words: CD ROM Caddy

Keywords: kbprb KB116451

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.