CD open close: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 2 | - | ||
| 3 | - | ||
| 4 | - | ||
| 5 | - | ||
| 6 | - | ||
| 1 | + | [](</File:Windows_logo_-_2012.svg>) | |
| 7 | 2 | ||
| 8 | - | ||
| 3 | + | This article applies to [Windows](</Category:Windows> "Category:Windows") only. | |
| 9 | 4 | ||
| 10 | - | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - | ||
| 14 | - | ||
| 15 | - | ||
| 5 | + | See also: [[Multiplatform Programming Guide]] | |
| 16 | 6 | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 7 | + | │ **[[CD open close/de|Deutsch (de)]]** │ **English (en)** │ | |
| 23 | 8 | ||
| 24 | - | ||
| 9 | + | These procedures open and close a CD / DVD drive: | |
| 25 | 10 | ``` | |
| 26 | - | ||
| 27 | - | ||
| 11 | + | uses MMSystem, ...; | |
| 12 | + | ||
| 13 | + | ... | |
| 14 | + | ||
| 15 | + | procedure TForm1.Button1Click(Sender: TObject); | |
| 16 | + | begin | |
| 17 | + | // opens the CD-ROM drive | |
| 18 | + | mciSendstring('SET CDAUDIO DOOR OPEN', nil , 0, Form1.Handle); | |
| 19 | + | mciSendString ('close cdlw', nil, 0, 0) | |
| 20 | + | end; | |
| 21 | + | ||
| 22 | + | procedure TForm1.Button2Click (Sender: TObject); | |
| 23 | + | begin | |
| 24 | + | // closes the CD-ROM drive | |
| 25 | + | mciSendstring('SET CDAUDIO DOOR CLOSED', nil , 0, Form1.Handle); | |
| 26 | + | mciSendString ('close cdlw', nil, 0, 0) | |
| 27 | + | end; | |
| 28 | + | ||
| 29 | + | ... | |
| 30 | + | ``` | |
| 28 | 31 | ||
| 29 | - | ||
| 32 | + | If you want to wait until the last operation is finished then this procedure will open/close a CD-ROM/DVD depending on the value of the **blnOpen** boolean variable: | |
| 33 | + | ``` | |
| 30 | 34 | uses | |
| 31 | - | ||
| 32 | - | ||
| 33 | - | ||
| 34 | - | ||
| 35 | - | ||
| 36 | - | ||
| 37 | - | ||
| 35 | + | MMSystem, ...; | |
| 36 | + | ||
| 37 | + | ... | |
| 38 | + | ||
| 39 | + | procedure cdOpenClose(chrDriveChar: char; blnOpen: boolean); | |
| 38 | 40 | begin | |
| 39 | - | ||
| 40 | - | ||
| 41 | - | ||
| 42 | - | ||
| 43 | - | ||
| 44 | - | ||
| 45 | - | ||
| 46 | - | ||
| 41 | + | if mciSendString(PChar('open ' + chrDriveChar + ': type cdaudio alias cdlw'), nil, 0, 0) = 0 then | |
| 42 | + | begin | |
| 43 | + | // open CD-ROM drive | |
| 44 | + | if blnOpen = True then | |
| 45 | + | mciSendString('set cdlw door open wait', nil, 0, 0) | |
| 46 | + | // close CD-ROM drive | |
| 47 | + | else | |
| 48 | + | mciSendString('set cdlw door closed wait', nil, 0, 0); | |
| 49 | + | ||
| 50 | + | mciSendString('close cdlw', nil, 0, 0); | |
| 51 | + | end; | |
| 47 | 52 | end; | |
| 48 | - | ||
| 49 | - | ||
| 50 | - | ||
| 51 | - | ||
| 53 | + | ||
| 54 | + | ... | |
| 52 | 55 | ``` | |
| 53 | 56 | ||
| 54 | 57 | --- | |
| 55 | - | ||
| 58 | + | *From the Free Pascal wiki, page "CD open close", as the Internet Archive kept it on 2025-02-15, last changed on 2020-02-11. 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).* |
