The CD Drive on my mother’s laptop was somewhat tricky to open (the button was a bit fiddly) so I threw together a utility so that she could double-click a shortcut from the desktop to pop open the drive.
I now use the utility myself, and figured it might be handy for other people as well.
You can download the utility here. Just unzip the executable and either put it directly on your desktop or create a shortcut to it. You will have to have some flavor of .NET 4 on your machine for it to work.
Update (10/15/15): Windows will helpfully block the executable when you first download and extract it, giving strange error messages when you try to run it. To fix this, right click on the executable, and click/check “Unblock”.
If you want to set up a shortcut to close the CD drive (and your drive supports it–many laptop drives do not) you can pass -c on the command-line.
The one limitation is that it only supports a single drive. It is actually relatively tricky to handle multiple drives, and since none of my machines have a second drive, I didn’t bother.
I’ll spend a few moments talking about the code (which is fairly concise). The application is a WinForms application. It could have been a console application, except that then you would see a command window appear briefly whenever you ran the app.
The way the application works is by sending a command string to the MCI (Media Control Interface) which is done via an external call to the method mciSendString. You need to do a DLLImport on the command:
[DllImport("winmm.dll", EntryPoint = "mciSendStringA")] public static extern int mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, int hwndCallback);
The default action is to open the CD drive, but the utility can also close the drive (if it is one that supports auto-closing–many laptop drives do not). Here are the command strings:
- set CDAudio door open
- set CDAudio door closed
The calling code just looks like this:
CDController.mciSendString("set CDAudio door open", (StringBuilder)null, (int)sbyte.MaxValue, 0);
That is pretty much all there is too it. There is a little bit of code to handle command-line arguments, but that is about it. Here is the source. Feel free to rename the application to Cup Holder and/or use it in any way you would like.