cdtray is a small program I wrote for a friend. It's pretty crappy. You even get to see a console window for a moment while the drive opens. All it does is open and close whatever drive you tell it to. That's what he wanted, that's what I gave him. I'm sure I could have made it prettier. I didn't. It was a 5-minute program. :)

To Protocol: the link has been fixed. You can now find the cdtray program here. In the future, please leave comments on an existing post rather than writing a draft post ;) [I fixed the problem that allowed you to do that in the first place].

Syntax examples:
cdtray.exe open D:
cdtray.exe close E:

The [lame] source code! :

Delphi [Show Plain Code]:
  1. program ejectcd;
  2. uses
  3.  SysUtils, MMSystem;
  4. var
  5.  str, str2: string;
  6. begin
  7.  if (ParamCount < 2) then halt;
  8.  str := lowercase(trim(ParamStr(1)));
  9.  str2 := 'open cdaudio!' + uppercase(trim(ParamStr(2))) + ' alias thedrive';
  10.  mciSendString(PAnsiChar(trim(str2)), nil, 0, 0);
  11.  if (str = 'close') then mciSendString('set thedrive door closed wait', nil, 0, 0);
  12.  if (str = 'open') then mciSendString('set thedrive door open wait', nil, 0, 0);
  13. end.