Torna al Thread
public partial class SimpleCopyCD : Form
{
public SimpleCopyCD_Main()
{
InitializeComponent();
CopyThreadObj = new SimpleCopy();
CopyThreadObj.OpenCDBay += new OpenCDBayHandler(OpenCDBay);
MyThread = new Thread(CopyThreadObj.CopyThreadMain);
MyThread.Start();
}
... bla
... bla
private void OpenCDBay(object sender, string str)
{
openDrive(str);
}
... bla
... bla
[DllImport("winmm.dll", EntryPoint = "mciSendString")]
public static extern int mciSendStringA(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);
private void openDrive(string driveRoot)
{
string driveLetter = driveRoot[0].ToString();
string returnString = string.Empty;
//Set a name for the specified disk drive
mciSendStringA("open " + driveLetter + ": type CDaudio alias drive" + driveLetter, returnString, 0, 0);
//open the disk tray
mciSendStringA("set drive" + driveLetter + " door open", returnString, 0, 0);
}