PDA

Click to See Complete Forum and Search --> : Eject CD-Rom problem using VB code


mikeng
Nov 29th, 1999, 10:23 PM
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

Serge
Nov 29th, 1999, 10:43 PM
This always works for me:


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
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)

Nov 30th, 1999, 01:00 AM
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: wossnamex@talk21.com :)

Aaron Young
Nov 30th, 1999, 01:35 AM
Use DOOR CLOSED in the Command String, if it's not Open it just won't do anything, eg.

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
aarony@redwingsoftware.com
adyoung@win.bright.net