0

I would like the same button to open the cd-tray when it's closed and to close it when it's open.

I am aware of the commands for opening or closing the CD-tray:

[DllImport("winmm.dll", EntryPoint = "mciSendString")]
public static extern int mciSendStringA(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);

My problem is that I don't know the status of the CD-tray, I only know how to check if a CD/DVD is loaded but not the status of the tray.

What I dislike is the idea of a variable memorizing the the status - as suggested in some threads I found - as this will get out of sync straightaway once the hardware button is pressed.

It must be possible though as some programs - eg itunes - do exactly what I would like to do.

Thanks in advance for any help.

  • possible duplicate of [C# How to tell if DVD drive tray is open?](http://stackoverflow.com/questions/6341737/c-sharp-how-to-tell-if-dvd-drive-tray-is-open) – Tymoteusz Paul Apr 22 '14 at 17:32
  • Duplicate of http://stackoverflow.com/questions/20764893/detect-when-cd-drive-was-closed – Faisal Apr 22 '14 at 17:33
  • Duplicate of [Check CD-ROM Tray Status](http://stackoverflow.com/questions/3969435/check-cd-rom-tray-status) – Black Frog Apr 22 '14 at 17:34
  • I had read those discussions before but they detect only when a CD is loaded; they do not differentiate between open and closed + empty which is what I need. – user3561468 Apr 22 '14 at 17:53
  • The link proposed at the top is not helpful as it is only a related question but does not contain an answer. To be specific: I do not necessarily want to know the status, I only want to use one button to open and close and as said this should be possible as other programs do it. – user3561468 Apr 22 '14 at 19:29

0 Answers0