This article demonstrates how to determine if the CD inserted is an audio CD or not.
procedure TForm1.Button1Click(Sender: TObject);
var
MyDeviceID : MCIDEVICEID;
MyOpenParams : TMCI_OPEN_PARMS;
MyStatusParams : TMCI_STATUS_PARMS;
MyError : LongInt;
MyErrorString : array[0..MAXERRORLENGTH - 1] of Char;
tmpStr : String;
begin
MyOpenParams.lpstrDeviceType := 'cdaudio';
MyError := mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE,
longint(@MyOpenParams));
if MyError <> 0 then
begin
MciGetErrorString(MyError,MyErrorString,MAXERRORLENGTH - 1);
Showmessage(MyErrorString);
Exit;
end;
MyDeviceID := mciGetDeviceID('cdaudio');
MyStatusParams.dwItem := MCI_CDA_STATUS_TYPE_TRACK;
MyStatusParams.dwTrack := 1;
MyError := mciSendCommand(MyDeviceID,
MCI_STATUS,
MCI_TRACK or
MCI_STATUS_ITEM,
Longint(@MyStatusParams));
case MyStatusParams.dwReturn of
MCI_CDA_TRACK_AUDIO : tmpStr := 'CDROM IS AUDIO';
MCI_CDA_TRACK_OTHER : tmpStr := 'CDROM IS NOT AUDIO';
end;
ShowMessage(tmpStr);
if MyError <> 0 then
begin
MciGetErrorString(MyError,MyErrorString,MAXERRORLENGTH - 1);
Showmessage(MyErrorString);
end;
MyError := mciSendCommand(MyDeviceID, MCI_CLOSE, 0, 0);
if MyError <> 0 then
begin
MciGetErrorString(MyError,MyErrorString,MAXERRORLENGTH - 1);
Showmessage(MyErrorString);
end;
end;