首页 新闻 赞助 找找看

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

0
悬赏园豆:50 [已关闭问题]

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

应该怎么写才可能呢?

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   );
    }
}
深水的猫的主页 深水的猫 | 初学一级 | 园豆:110
提问于:2008-08-31 00:16
< >
分享
其他回答(1)
0
mciSendString( "set h:\ cdaudio door open", null, 0, IntPtr.Zero ); mciSendString( "set h:\ cdaudio door closed", null, 0, IntPtr.Zero ); h:\ 是你指定的驱动器号
eaglet | 园豆:17139 (专家六级) | 2008-09-01 08:03
0
我也很好奇,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);
zjy | 园豆:3194 (老鸟四级) | 2008-09-01 16:37
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册