+92 332 4229 857 99ProjectIdeas@Gmail.com

Cd-Rom Opening and Closing (C#.net)


Cd-Rom Opening And Closing:
The following program shows you how to open and close the cd-rom.


Code

using System.Runtime.InteropServices;

[DllImport("winmm.dll",EntryPoint="mciSendStringA",
 ExactSpelling=true, CharSet=CharSet.Ansi, SetLastError=true)]
                    
public static extern long mciSendString(string lpCommandString, string lpReturnString, long uReturnLength, long hwndCallback);
               
public void btnOpen_Click(System.Object sender, System.EventArgs e)
{
       mciSendString("set CDAudio door open", "", 0, 0);
}
             
public void btnClose_Click(System.Object sender, System.EventArgs e)
{
       mciSendString("set CDAudio door closed", "", 0, 0);
}

0 comments: