This article demonstrates how to open / close the CD tray in Delphi.
uses MMSystem;
procedure TForm1.OpenCdTray(AOpen:Boolean);
const
DoPlay : array[Boolean] of String =
('Set cdaudio door closed wait',
'Set cdaudio door open wait');
var
MyError : LongInt;
MyErrorString : array[0..MAXERRORLENGTH - 1] of char;
begin
MyError := mciSendString(pChar(DoPlay[AOpen]), nil, 0, 0);
if MyError <> 0 then
begin
MciGetErrorString(MyError,MyErrorString,MAXERRORLENGTH - 1);
Showmessage(MyErrorString);
Exit;
end;
end;