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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RuchiCommented:

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.