码迷,mamicode.com
首页 > 其他好文 > 详细

打开或关闭CD_ROM

时间:2019-01-16 18:05:55      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:.com   div   img   ptr   obj   api   rom   效果   eve   

实现效果:

  技术分享图片

知识运用:

  API函数 mciSendString  //函数用来向媒体控制接口设备发送命令  声明如下

[DllImport("winmm.dll",EntryPoint="mciSendString")]
public static extern int mciSendString(string IpstrCommand,string IpstrReturnString,System.UInt16 uReturnLength,System.IntPtr HwndCallback);

技术分享图片

 实现代码:

    [DllImport("winmm.dll",EntryPoint="mciSendString")]
    public static extern int mciSendString(string IpstrCommand,string IpstrReturnString,System.UInt16 uReturnLength,System.IntPtr HwndCallback);

    private void button1_Click(object sender, EventArgs e)
    {
        mciSendString("Set cdaudio door open wait","",0,this.Handle);         //打开CD_ROM
    }

    private void button2_Click(object sender, EventArgs e)
    {
        mciSendString("Set cdaudio door closed wait", "", 0, this.Handle);     //关闭CD_ROM
    }

  

打开或关闭CD_ROM

标签:.com   div   img   ptr   obj   api   rom   效果   eve   

原文地址:https://www.cnblogs.com/feiyucha/p/10278221.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!