4

How do I open the CD/DVD door with a Windows API call?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
gemisigo
  • 205
  • 4
  • 12

3 Answers3

6

If you're using .NET this will work:

http://www.dotnetspider.com/resources/15834-eject-close-cd-tray.aspx

It was the first link to come up when I googled "win api open cd door".

This was the second one: Windows CDROM Eject.

Community
  • 1
  • 1
David
  • 72,686
  • 18
  • 132
  • 173
1

If anyone else is interested, here is a short draft of how it can be done in Lua:

require ("alien")

local kolbasz = alien.winmm.mciSendStringA
kolbasz:types{ ret = 'long', abi = 'stdcall', 'string', 'string', 'long', 'long'}
kolbasz("set cdaudio door open", null, 0, 0)
gemisigo
  • 205
  • 4
  • 12
1
[DllImport("winmm.dll")]
static extern Int32 mciSendString(string command, string buffer, int bufferSize, IntPtr hwndCallback);

//Open
mciSendString("set CDAudio door open", "", 127, IntPtr.Zero);

//Close
mciSendString("set CDAudio door closed", "", 127, IntPtr.Zero);
Sergio Cabral
  • 6,490
  • 2
  • 35
  • 37