Test if a CD is in the drive lazarus / 8-Other ---------------------------------------------------------------------- bonmario · 2007-03-29 05:56 Hi to all, i ise this code to test if a CD/DVD is in the drive: function DiskInDrive(Drive: Char): Boolean;  var ErrorMode: word; begin  { rendi il char maiuscolo }  UpCase(Drive);  { assicurati che sia una lettera }  if not (Drive in ['A'..'Z']) then   raise EConvertError.Create('Not a valid drive ID');  { disabilita errori critici }  ErrorMode := SetErrorMode(SEM_FailCriticalErrors);  try   { drive 1 = a, 2 = b, 3 = c, etc. }   Result := NOT (DiskSize(Ord(Drive) - $40) = -1);  finally   { riabilia errori critici }   SetErrorMode(ErrorMode);  end; end; But this code return false if in the drive there is a new CD / DVD (empty). Someone know how solve this problem? Thanks, Mario ---------------------------------------------------------------------- antonio · 2007-03-29 19:03 Try function DiskFree(Drive: Byte): Integer; ---------------------------------------------------------------------- bonmario · 2007-04-02 06:00 Quote from: "antonio"Try function DiskFree(Drive: Byte): Integer; The result is the same :-((( ---------------------------------------------------------------------- antonio · 2007-04-02 07:54 This function should return Free Disk Space... Are the CDs formatted? ---------------------------------------------------------------------- bonmario · 2007-04-03 05:51 Quote from: "antonio"This function should return Free Disk Space... Are the CDs formatted? The CD / DVD is new and contains no data. DiskFree return -1