Using the code from
Open & close CD tray in C#
Create the following class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace dummyProj1
{
class DVD
{
[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi)]
protected static extern int mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, IntPtr hwndCallback);
public bool ProcessCDTray(bool open)
{
int ret = 0;
switch (open)
{
case true:
ret = mciSendString("set cdaudio door open", null, 0, IntPtr.Zero);
return true;
case false:
ret = mciSendString("set cdaudio door closed", null, 0, IntPtr.Zero);
return true;
default:
ret = mciSendString("set cdaudio door open", null, 0, IntPtr.Zero);
return true;
}
}
}
}
To Open the DVD Tray, use the following bit of code:
DVD thedvd = new DVD();
thedvd.ProcessCDTray(true);
thedvd.ProcessCDTray(false);