Solved

Control the CD Tray with C#

Posted on 2004-09-13
3
427 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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

837 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