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

我机器上有两光驱,下面这段代码只能弹出第一个光驱,无法指定弹出第二个光驱。

应该怎么写才可能呢?

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   );
    }
}


温温酱
浏览 581回答 2
2回答

梦里花落0921

我也很好奇,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);
打开App,查看更多内容
随时随地看视频慕课网APP