您的位置:首页 > 编程语言 > C#

C#中调用系统API打开和关闭光驱

2008-09-11 22:16 429 查看

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

class CloseCD
{
//API声明

[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 );//关闭光区
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐