Open or close the CD drive

Description :

We can open and close the tray of the CD drive of the system.

Following are the namespaces

using System.Runtime.InteropServices;
using System.Text;

Following is the DLL import part.

[DllImport("winmm.dll", EntryPoint="mciSendStringA", CharSet=CharSet.Ansi)]
protected static extern int MymciSendString
(string mciCommand,
StringBuilder returnValue,
int returnLength,
IntPtr callback);

Following is the code part to open and close the CD drive

public static void Main( )
int result = MymciSendString
("open the door ", null, 0, IntPtr.Zero);
result = MymciSendString ("close the door",
null, 0, IntPtr.Zero);



No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: