
Need help on CD-Rom door using DoEvents???
Hi,
I could really use some help on this.
I'm trying to open/close the CD-ROM door
from within VB. So far my program can
open the door, (Command1), and immediately
close the door, (Command2). After the door
is closed, the system trys to read the CD
Header or someting. This takes about 15 secs.
I've placed a Timer and a Textbox to count
down from 15 to 0 the amount af secs it takes
to do this.
Problem is that after closing the door,
everything stops while the CD is being read.
How can I keep the timer running and
displaying the count down time in the Textbox
while the CD is being read??
I've tried DoEvents all over the place but,
so far everything stops during this read.
Thanks,
Magic
***** Th following is my Code
Option Explicit
Private Sub Command1_Click()
CDDoorOpen "True"
End Sub
Private Sub Command2_Click()
Text1.Text = 15
Text1.Visible = True
CDDoorOpen "False"
End Sub
Private Sub Form_Load()
Text1.Visible = False
End Sub
Private Sub Timer1_Timer()
Text1.Text = Text1.Text - 1
If Text1.Text = 0 Then
Text1.Text = 15
End If
End Sub
***** The following is my Modual.bas
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
Sub CDDoorOpen(YesNo As Boolean)
Dim returnstring As String
Dim retvalue As String
Dim SW As String
'==================================================
If YesNo Then
'To open the CD door, use this code
retvalue = mciSendString("Set CDAudio door open", "", 0, 0)
'retvalue = mciSendString("set CDAudio door open", _
' returnstring, 127, 0)
Else
'To close the CD door, use this code
retvalue = mciSendString("Set CDAudio door closed", "", 0, 0)
'retvalue = mciSendString("set CDAudio door closed", _
' returnstring, 127, 0)
End If
End Sub