Get the serial number of an audio CD  

Send By: Radikal (Q3 Team)
Web : http://www.q3.nu
Email: radikal@q3.nu
Date: 19/04/00

Tip accessed 462 times

 




 procedure TForm1.Button1Click(Sender: TObject);

   function AudioCDNum(Unidad: char):string;
   var
     mp            : TMediaPlayer;
     MInfo         : TMCI_INFO_PARMS;
     SerialN       : array[0..255] of char;

   begin
     Result:='';
     mp := TMediaPlayer.Create(nil);

     try
       with mp do
       begin
         Visible    := false;
         Parent     := Application.MainForm;
         Shareable  := true;
         DeviceType := dtCDAudio;
         FileName   := Unidad+':';
         Open;
       end;
       Application.ProcessMessages;

       FillChar(SerialN, sizeof(SerialN), #0);
       FillChar(MInfo, sizeof(MInfo), #0);
       MInfo.lpstrReturn := @SerialN;
       MInfo.dwRetSize := 255;
       if mciSendCommand(Mp.DeviceId,
                         MCI_INFO,
                         MCI_INFO_MEDIA_IDENTITY,
                         longint(@MInfo)) <> 0
         then Raise Exception.Create('Error');
       mp.Close;

       Result:=String(SerialN);
     finally
       Application.ProcessMessages;
       mp.free;
     end;
   end;

 begin
   Label1.Caption:=AudioCDNum('F');
 end;