c#打开关闭CD/DVD光驱代码

来自:http://outofmemory.cn/code-snippet/470/c-open-close-CD-DVD-guangqu-code

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);


 

你可能感兴趣的:(█小小代码,C#基础知识)