Disk in Drive: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Disk in Drive
| Old | New | Line | |
|---|---|---|---|
| 1 | + | [](</File:Windows_logo_-_2012.svg>) | |
| 2 | + | ||
| 3 | + | This article applies to [Windows](</Category:Windows> "Category:Windows") only. | |
| 4 | + | ||
| 5 | + | See also: [[Multiplatform Programming Guide]] | |
| 6 | + | ||
| 7 | + | │ **[[Disk in Drive/de|Deutsch (de)]]** │ **English (en)** │ | |
| 8 | + | **** | |
| 9 | + | ||
| 10 | + | The function checks whether there is a disk medium in the CD or DVD drive. | |
| 11 | + | ``` | |
| 12 | + | uses | |
| 13 | + | SysUtils, ...; | |
| 14 | + | ||
| 15 | + | // enumeration for the return values | |
| 16 | + | grade | |
| 17 | + | byte = (enmNoDriveLetter, enmMoMedInserted, enmMedInserted, enmError); | |
| 18 | + | ||
| 19 | + | ... | |
| 20 | + | ||
| 21 | + | function funDiskInDrive (chrDrive : char) : byte; | |
| 22 | + | begin | |
| 23 | + | ||
| 24 | + | Result := enmNoDriveLetter; | |
| 25 | + | chrDrive := UpCase(chrDrive); | |
| 26 | + | ||
| 27 | + | // Checks whether the drive letter is valid. | |
| 28 | + | if not (chrDrive in ['A' .. 'Z']) then | |
| 29 | + | exit; | |
| 30 | + | ||
| 31 | + | // Checks if the drive contains media. | |
| 32 | + | try | |
| 33 | + | if DiskSize ( Ord ( chr drive ) - $ 40 ) <> - 1 then | |
| 34 | + | Result := enmMedInserted | |
| 35 | + | else | |
| 36 | + | Result := enmNoMedInserted; | |
| 37 | + | except | |
| 38 | + | Result := enmError; | |
| 39 | + | end; | |
| 40 | + | ||
| 41 | + | end; | |
| 42 | + | ||
| 43 | + | ... | |
| 44 | + | ``` | |
| 45 | + | ||
| 46 | + | Example of calling the function: | |
| 47 | + | ``` | |
| 48 | + | ... | |
| 49 | + | ||
| 50 | + | case funDiskInDrive('F') of | |
| 51 | + | enmNoDriveLetter : ... ; | |
| 52 | + | enmNoMedInserted : ... ; | |
| 53 | + | enmMedInserted : ... ; | |
| 54 | + | Error : ... ; | |
| 55 | + | end; | |
| 56 | + | ||
| 57 | + | ... | |
| 58 | + | ``` | |
| 59 | + | ||
| 60 | + | --- | |
| 61 | + | *From the Free Pascal wiki, page "Disk in Drive", as the Internet Archive kept it on 2025-04-21. 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](/wiki-contact).* |
