Windows CDROM 弹出 [英] Windows CDROM Eject

查看:15
本文介绍了Windows CDROM 弹出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道在 Windows 2000 或更高版本上以编程方式关闭 CD 托盘的方法吗?存在打开的 CD 托盘,但我似乎无法将其关闭,尤其是在 W2k 下.

如果可能的话,我特别在寻找一种从批处理文件中执行此操作的方法,但 API 调用也可以.

解决方案

以下是使用 Win32 API 的简单方法:

<预><代码>[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi)]受保护的静态外部 int mciSendString(string lpstrCommand,StringBuilder lpstrReturnString,int uReturnLength,IntPtr hwndCallback);public void OpenCloseCD(bool Open){如果(打开){mciSendString("设置cdaudio 门打开", null, 0, IntPtr.Zero);}别的{mciSendString("设置 cdaudio 门关闭", null, 0, IntPtr.Zero);}}

Does anyone know a method to programmatically close the CD tray on Windows 2000 or higher? Open CD tray exists, but I can't seem to make it close especially under W2k.

I am especially looking for a method to do this from a batch file, if possible, but API calls would be OK.

解决方案

Here is an easy way using the Win32 API:


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

 public void OpenCloseCD(bool Open)
 {
    if (Open)
    {
        mciSendString("set cdaudio door open", null, 0, IntPtr.Zero);
    }
    else
    {
        mciSendString("set cdaudio door closed", null, 0, IntPtr.Zero);
    }
}

这篇关于Windows CDROM 弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆