Open/close CD drive tray
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
| C# Code Snippets |
| See also |
| edit |
This C# code snippet opens and closes the tray of the CD drive.
using System.Runtime.InteropServices; using System.Text; ... public static void Main( ) { int result = mciSendString ("set cdaudio door open", null, 0, IntPtr.Zero); result = mciSendString ("set cdaudio door closed", null, 0, IntPtr.Zero); } [DllImport("winmm.dll", EntryPoint="mciSendStringA", CharSet=CharSet.Ansi)] protected static extern int mciSendString (string mciCommand, StringBuilder returnValue, int returnLength, IntPtr callback);