要想打开光驱用C#语言怎么写代码
要想打开光驱用C#语言怎么写代码
------解决方案--------------------网上找的,测试通过
在开始加入using System.Runtime.InteropServices;
在类中加入
[DllImport( "winmm.dll ", EntryPoint= "mciSendString ",CharSet=CharSet.Auto)]
public static extern int mciSendString (string lpstrCommand,string lpstrReturnstring ,int uReturnLength,int hwndCallback);
加入两个按钮,
private void opencdrom_Click(object sender, System.EventArgs e)
{
long lngReturn = mciSendString( "set CDAudio door open ", null, 127, 0);
}
private void closecdrom_Click(object sender, System.EventArgs e)
{
long lngReturn = mciSendString( "set CDAudio door closed ", null, 127, 0);
}