Solved

Control the CD Tray with C#

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using YubiKey with REST API application 2 117
Magic Software info 18 130
How can i compile this github project?? 2 84
Hide vba in gp 7 94
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

773 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