Solved

Control the CD Tray with C#

Posted on 2004-09-13
3
421 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
  • 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now