Disk in Drive
Deutsch · English
The function checks whether there is a disk medium in the CD or DVD drive.
uses
SysUtils, ...;
// enumeration for the return values
grade
byte = (enmNoDriveLetter, enmMoMedInserted, enmMedInserted, enmError);
...
function funDiskInDrive (chrDrive : char) : byte;
begin
Result := enmNoDriveLetter;
chrDrive := UpCase(chrDrive);
// Checks whether the drive letter is valid.
if not (chrDrive in ['A' .. 'Z']) then
exit;
// Checks if the drive contains media.
try
if DiskSize ( Ord ( chr drive ) - $ 40 ) <> - 1 then
Result := enmMedInserted
else
Result := enmNoMedInserted;
except
Result := enmError;
end;
end;
...Example of calling the function:
...
case funDiskInDrive('F') of
enmNoDriveLetter : ... ;
enmNoMedInserted : ... ;
enmMedInserted : ... ;
Error : ... ;
end;
...From the Free Pascal wiki, page "Disk in Drive", as it stood on 2020-02-13 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.
Edited on wiki.freepascal.org by 1 person, 2020
From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.
| When | Who | What changed |
|---|---|---|
| Trev | English translation of German page |
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
