Open the CD / DVD door with a call to the Windows API?

How to open a CD / DVD door with a call to Windows API?

+3
source share
3 answers

If you use .NET, this will work:

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

This was the first link that appeared when I googled "win api open cd door".

This was the second: Removing the CD-ROM for Windows .

+6
source

If anyone else is interested, here is a brief draft of how this 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)
+1
source
[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);
+1
source

Source: https://habr.com/ru/post/1724438/


All Articles