为了账号安全,请及时绑定邮箱和手机立即绑定

在C#中如何判弹出所有光驱?

在C#中如何判弹出所有光驱?

温温酱 2018-12-25 14:04:20
我机器上有两光驱,下面这段代码只能弹出第一个光驱,无法指定弹出第二个光驱。应该怎么写才可能呢?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   );    }}
查看完整描述

2 回答

?
梦里花落0921

TA贡献1772条经验 获得超5个赞

我也很好奇,google一下,答案如下: //M:是光驱所在的盘符 mciSendString('open M: type CDAudio alias finch wait', nil, 0, Self.Handle); //打开光驱 mciSendString('set finch door open wait', nil, 0, Self.Handle); //关闭光驱 // mciSendString('set finch door closed wait', nil, 0, Self.Handle); mciSendString('Close finch', nil, 0, Self.Handle);

查看完整回答
反对 回复 2018-12-29
  • 2 回答
  • 0 关注
  • 580 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信