Link to home
Start Free TrialLog in
Avatar of DOOM_DAEMON
DOOM_DAEMON

asked on

Open(Eject) And Close CD-ROM Tray in code....How to do ?

       I know that Delphi can open CD-Rom Tray (Eject) But I don't know how to close it in code...Anyone outthere can show me a fully coded procedure to do so...I want it to open(Eject) and Close with a Button "Open" and "Close" Shown on form...
ASKER CERTIFIED SOLUTION
Avatar of Mohammed Nasman
Mohammed Nasman
Flag of Palestine, State of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stuart_Johnson
Stuart_Johnson

This is the code I was using a while ago to do what you need, but I'm not sure if it works still.

To open the CD-ROM:

mciSendString('Set cdaudio door open wait', nil, 0, handle);

To close the CD-ROM:

mciSendString('Set cdaudio door closed wait', nil, 0, handle);

You need to have MMSystem declared in your uses clause.

HIH.

Stu.
Damn you have to be quick ;)  In the time it took me to open Explorer, locate the project, open the PAS file, copy and paste it, the same code was already provided.  You're fast mnasman :)

Stu
Hi Stuart,

Its a kind of Magic. Create your own Knowledge Base to store some Tricks & Tips an Artikes ;-)

Some Experts here are using Clients. This clients tell us there is a new Question.......

Have a nice live

Cesario
What would the commands be if you have more than one cd-rom? In other words a cd-rom and a cd-writer.
Dear skynergy,

AFAIK the device name in Specified in the SYSTEM.INI file.

Example:
[mci]
cdaudio=mcicda.drv
sequencer=mciseq.drv
waveaudio=mciwave.drv
avivideo=mciavi.drv
videodisc=mcipionr.drv
vcr=mcivisca.drv
MPEGVideo=mciqtz.drv
MPEGVideo2=mciqtz.drv


Best Regards

Cesario
Thanx for your quick response!