Programatically ejecting and retracting the CD drive in vb.net or c#

后端 未结 2 1464
隐瞒了意图╮
隐瞒了意图╮ 2020-12-09 14:05

Is there any way to do so? I know its possible to programmatically eject/retract the cd drive SOMEHOW, cause Roxio does that when it prompts me to insert a disk.

Eit

2条回答
  •  暖寄归人
    2020-12-09 14:37

    using System.Runtime.InteropServices;
    
    [DllImport("winmm.dll")]
    static extern Int32 mciSendString(String command, StringBuilder buffer, Int32 bufferSize, IntPtr hwndCallback);
    
    // To open the door
    mciSendString("set CDAudio door open", null, 0, IntPtr.Zero);
    
    // To close the door
    mciSendString("set CDAudio door closed", null, 0, IntPtr.Zero);
    

    http://www.geekpedia.com/tutorial174_Opening-and-closing-the-CD-tray-in-.NET.html

提交回复
热议问题