diskinfo Example - Reading CD-ROM information
dcDiskInfo component
Return to Introduction  Previous page  Next page
Following example demonstrates how to determinate the letter of CD-ROM drive and read the information about current CD. Code below detects the CD-drive and shows the serial number of CD.


procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
begin
  for I := Length(dcDiskInfo1.AvailableDrives) downto 1
 do
   begin
    dcDiskInfo1.Disk := dcDiskInfo1.AvailableDrives[I];
    if dcDiskInfo1.DriveType = dtCDROM then
     begin
      if dcDiskInfo1.DiskSize <> -1
 then // Disk inserted
        ShowMessage('Serial number of CD in drive '
 + dcDiskInfo1.Disk + ': is ' + dcDiskInfo1.SerialNumberStr)
      else // no disk

        ShowMessage('CD-ROM drive is 
' + dcDiskInfo1.Disk + ':, but you need to insert the disk before read its serial number.');
      Exit;
     end;
   end;
  ShowMessage('CD-ROM not found.'
); 
end;
File not found.