Otevreni/Zavreni dvirek CD mechaniky v DELPHI nebo C++ Builderu
a hlavne hledam takovou fci aby fungovala i v konfiguraci vice mechanik
(ne jen na prvni)
Help please ...
Printable View
Otevreni/Zavreni dvirek CD mechaniky v DELPHI nebo C++ Builderu
a hlavne hledam takovou fci aby fungovala i v konfiguraci vice mechanik
(ne jen na prvni)
Help please ...
navodu je na netu hafo. staci si vybrat ;)
neboKód:// X je oznaceni pismena mechaniky
mciSendString('open cdaudio!X: alias driveX', nil, 0, 0);
mciSendString('set driveX door open wait', nil, 0, 0);
// a todle pro zavreni
mciSendString('set driveX door closed wait', nil, 0, 0);
Kód:function IsDriveCD(Drive : char) : longbool;
var
DrivePath : string;
begin
DrivePath := Drive + ':\';
result := LongBool(GetDriveType(PChar(DrivePath)) and RIVE_CDROM);
end;
function EjectCD(Drive : char) : bool;
var
mp : TMediaPlayer;
begin
result := false;
Application.ProcessMessages;
if not IsDriveCD(Drive) then exit;
mp := TMediaPlayer.Create(nil);
mp.Visible := false;
mp.Parent := Application.MainForm;
mp.Shareable := true;
mp.DeviceType := dtCDAudio;
mp.FileName := Drive + ':';
mp.Open;
Application.ProcessMessages;
mp.Eject;
Application.ProcessMessages;
mp.Close;
Application.ProcessMessages;
mp.free;
result := true;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if not EjectCD('D') then
ShowMessage('Not A CD Drive');
end;
dikCitace:
Původně odeslal jedik
me se osvedcilo http://forum.builder.cz/read.php?f=18&i=4115&t=4115