aperlitz
asked on
cd-tray open or closed
how can i check in delphi 2.0 if the cd-tray is open or closed?
how can i check if an audio-cd is inserted or a data-cd? checking for playable tracks doesn't work.
how can i check if an audio-cd is inserted or a data-cd? checking for playable tracks doesn't work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
the tip about checking for audio-cd's is perfect. works really great. but i need to know how i can check if the door is open or closed. i know, how to open and to close the door, but i want to let the user do this by clicking only one button. so the state of the door has to be checked when the user clicks the button. any suggestions about this? (i knew cdevents.pas before, but it didn't help me).
aperlitz
The code I sent you will do it exactly that it closes the cd door if it's open to close it just cahnge the close stuff to open...
If you still need help leave your mail address and I'll send a example to you...
Later
BoRiS
The code I sent you will do it exactly that it closes the cd door if it's open to close it just cahnge the close stuff to open...
If you still need help leave your mail address and I'll send a example to you...
Later
BoRiS
Well, Boris, both our comments weren't answeres. Why didn't you just leave the question open?
http://www.delphipages.com/edit/count.cfm?comID=367&Link=uploads%2FSystem%5FAPI%2FCDEvnt14%2Ezip
(all thanks go to ZifNab!)
ZifNab also found this pice of source for me once:
Q) How can I tell if a given CD-ROM Drive contains an Audio CD?
A) You can use the Windows API function GetDriveType() to test
if the drive is a CD-ROM drive then use the Windows API function
GetVolumeInformation() to test if the VolumeName is 'Audio CD'.
Example:
function IsAudioCD(Drive : char) : bool;
var
DrivePath : string;
MaximumComponentLength : DWORD;
FileSystemFlags : DWORD;
VolumeName : string;
begin
Result := false;
DrivePath := Drive + ':\';
if GetDriveType(PChar(DrivePa
SetLength(VolumeName, 64);
GetVolumeInformation(PChar
if lStrCmp(PChar(VolumeName),
end;
function PlayAudioCD(Drive : char) : bool;
var
mp : TMediaPlayer;
begin
result := false;
Application.ProcessMessage
if not IsAudioCD(Drive) then exit;
mp := TMediaPlayer.Create(nil);
mp.Visible := false;
mp.Parent := Application.MainForm;
mp.Shareable := true;
mp.DeviceType := dtCDAudio;
mp.FileName := Drive + ':';
mp.Shareable := true;
mp.Open;
Application.ProcessMessage
mp.Play;
Application.ProcessMessage
mp.Close;
Application.ProcessMessage
mp.free;
result := true;
end;
procedure TForm1.Button1Click(Sender
begin
if not PlayAudioCD('D') then
ShowMessage('Not an Audio CD');
end;
Joe
--
Joe C. Hecht
joehecht@gte.net