在uses中增加mmsystem单元。
procedure TForm1.N12Click(Sender: TObject);
var
ejectcd:boolean;
begin
{弹出或关闭CD-COM}
mciExecute('open cdaudio alias cd shareable ');
if EjectCD=true then
begin
mciExecute('set cddo
or open');
EjectCD:=false;
end
else
begin
mciExecute('set cddo
or closed');
EjectCD:=true;
end;
mciExecute('close cd');
end;