现在的位置: 首页 > 综合 > 正文

C#怎样打开关闭CDROM?

2012年05月31日 ⁄ 综合 ⁄ 共 458字 ⁄ 字号 评论关闭

using System;
using System.Text;
using System.Runtime.InteropServices;

class CloseCD
{

  [DllImport( "winmm.dll", EntryPoint="mciSendStringA", CharSet=CharSet.Ansi )]
  protected static extern int mciSendString( string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, IntPtr hwndCallback );

  public static void Main()
  {

    int ret = mciSendString( "set cdaudio door open", null, 0, IntPtr.Zero );

    Console.ReadLine();
 
    ret = mciSendString( "set cdaudio door closed", null, 0, IntPtr.Zero );
  }
}

抱歉!评论已关闭.