MMSYSTEM
in the USES
-list):
procedure TForm1.FormCreate(Sender: TObject);
var
InfoParm : TMCI_Info_Parms;
lpInfoString : PChar;
const
lenInfoString = 17;
begin
{ activate MediaPlayer1 to get the DeviceID }
MediaPlayer1.DeviceType := dtCDAudio;
if not MediaPlayer1.AutoOpen then MediaPlayer1.Open;
{ prepare record: }
GetMem(lpInfoString,lenInfoString);
InfoParm.dwCallback := 0;
InfoParm.lpstrReturn := lpInfoString;
InfoParm.dwRetSize := lenInfoString;
{ get unique ID }
mciSendCommand(MediaPlayer1.DeviceID,
mci_Info,
(mci_Wait or MCI_INFO_MEDIA_IDENTITY),
Longint(@InfoParm) );
{ here comes the result: }
Edit1.Text := IntToHex(StrToInt(lpInfoString),1);
FreeMem(lpInfoString,lenInfoString);
end;
Convert the result string to an integer and then to a hex string like shown above to get the id used in cdplayer.ini.
Note:
On audio cds with less than three tracks, the result from the procedure above is different from the value returned
by GetVolumeInformation
or the other methods named in the Q&A.
The difference seems to be the offset of the first track in frames. However, the result from the call shown here is the one used in cdplayer.ini (and DeluxeCD.mdb).