how to open and close CD with one program

Is there any way to eject the CD tray and close it in a program like a
toggle ?

If the cd is closed, open it.  If the cd is open, close it ?

I would like to assign a program like this to my multimedia keyboard, which
doesn't have an eject cd button.  Which gets to be a pain since it has play
and such.

Thanks
supprogAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
RuchiConnect With a Mentor Commented:

Dim retvalue As Integer
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()
retvalue = mciSendString("set CDAudio door open", "", 127, 0)
End Sub

Private Sub Command2_Click()
retvalue = mciSendString("set CDAudio door closed", "", 127, 0)
End Sub
0
 
RuchiCommented:
If it's not Open it just won't do anything, try this..

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
0
 
supprogAuthor Commented:
Aswome, small and concise and it works great.

Thanks for the help
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
supprogAuthor Commented:
The only problem I have is if I try to put this into a form load, so all I have to do is run this thing, and I do not have to click any buttons or anything, the function does not work.

It works great if I put it into a button, but it doesn't seem to work right in a form load.

Any ideas ?
0
 
RuchiCommented:
I tried to do what you said the above. It opens when the program runs. It seems to be working only in a click event.... But, all I can say is that I don't have any ideas.
0
 
supprogAuthor Commented:
Oh well, it was worth a shot.  I also found a bunch of programs on ZD Hot Files, and they either just open the door, or if they do an open and close, they leave an icon in the taskbar.  So your first idea would then come into play, where the program would be left running and then could keep track of the variable.

Oh, well, I am going to use your first idea, but just use the open, and not the close.

0
 
RuchiCommented:
Supprog!

Post your e-mail address here. I will send you an e-mail message along with the source code. It puts a CD door open/close control on the system tray using VB. Increase more points for that. :)

Did you read the comments to your DB question? Please let me know how you are doing with that...
0
 
supprogAuthor Commented:
Here is my email:
supprog@earthlink.net

I would be happy to increase points, but what I setup in the beginning is all I have available.  If you know of a way I can increase my points, I would be happy to help.

On the DB question, I still haven't found an easy answer.  I know there are alternatives, such as the ones you posted.  But, for the time being, I found it much easier to convert the database to pre-2000 version, and use DAO.

If I need to modify the database, which is not often, I have to convert it to 2000, modify then convert back.

This will have to dfor the time being, as I do not have time to learn ADO right now.

Thanks for the help
0
 
RuchiCommented:
My e-mail message is on the way to you.
0
All Courses

From novice to tech pro — start learning today.