Solved

Control the CD Tray with C#

Posted on 2004-09-13
3
429 Views
Last Modified: 2008-03-03
I want to write a program to control my CD tray . To make it in and out . Eject and back. I triead to check the msdn but couldn't find what I wanted. Does any body know the class we can use for that task ?
If any other ideas or tips are available please mention.
0
Comment
Question by:drtoto82
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
Desp earned 125 total points
ID: 12051455
you can use the mciSendString API for this

using System.Runtime.InteropServices;
 
[DllImport("winmm", EntryPoint="mciSendStringA")]
private static extern int mciSendString(string lpszCommand,  string lpszReturnString, int cchReturnLength, int hwndCallback);


         private void button1_Click(object sender, System.EventArgs e)
         {
              mciSendString("Set cdaudio door open wait", "", 0, 0);
         }

         private void button2_Click(object sender, System.EventArgs e)
         {
           mciSendString("Set cdaudio door closed wait", "", 0, 0);
         }
0
 
LVL 5

Author Comment

by:drtoto82
ID: 12052123
Your reply was perfect. I just had the idea but was messed up in my mind. The thing I want to ask you here, how can I get that data about the dll I am importing and refering to like the one you used winmm,dll ? Sounds foolish , but I always used my dlls and declared everything as public and of course I know the code I wrote for my self.
0
 
LVL 19

Expert Comment

by:Desp
ID: 12052145
you mean all the functions(APIs) information in that winmm.DLL (or any DLL) ? through a C# program?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Please help| Getting the syntax error in below query. 2 78
youtube blocking politics 4 100
storing csv file in table variable in Python 2 92
Is online banking safe? 11 116
A short article about problems I had with the new location API and permissions in Marshmallow
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question