欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

C#怎样打开关闭CDROM 博客分类: C# C#怎样打开关闭CDROMc# 

程序员文章站 2024-03-22 18:20:34
...

C#怎样打开关闭CDROM?
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 );
  }
}