C#中调用系统API打开和关闭光区
2006-05-15 23:26 蓝之风 阅读(497) 评论(0) 编辑 收藏 举报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 );//关闭光区
}
}
作者:蓝之风
出处:http://www.cnblogs.com/vaiyanzi/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。