Wednesday, December 28, 2005

tag

function EjectCD: boolean;
var mp : TMediaPlayer;
begin
mp := TMediaPlayer.Create(nil);
mp.Visible := false;
mp.Parent := Application.MainForm;
mp.Shareable := true;
mp.DeviceType := dtCDAudio;
mp.Open;
mp.notify:=true;
mp.Eject;
if mp.notify=false then result:=false
else result:=true;
mp.Close;
mp.free;
end;


function CloseCD:boolean;
var mp : TMediaPlayer;
begin
result := false;
mp := TMediaPlayer.Create(nil);
mp.Visible := false;
mp.Parent := Application.MainForm;
mp.Shareable := true;
mp.DeviceType := dtCDAudio;
mp.Open;
mciSendCommand(mp.DeviceID, MCI_SET, MCI_SET_DOOR_CLOSED, 0);
mp.Close;
mp.free;
result := true;
end;