• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# How do you open the cd-rom in c++

## Recommended Posts

v0id    122
Just wondering if anyone could give me the code to open the CD-ROM drive in c++ in windows

##### Share on other sites
NickB    146
In what way ? do you just want to open files, in which case the standard methods (fopen, CreateFileEx etc.) will work fine - or do you want to be able to read the raw data - block by block - like a MP3 ripper ? - in that case try searching for AKRIP - I can''t remember the address - I think it may be on source forge - but anyhow it''s an open source program that uses WNASPI to access the CD & read the raw data - I think it''s also got some ASPI tuts

##### Share on other sites
guitarman310    122
i think he means to open the cd rom bay door...i''m not sure, check MSDN.

##### Share on other sites
Beer Hunter    712
If you''re trying to eject the cd-rom, then it''s not too hard:

#include <mmsystem.h>

mciSendString("set cdaudio door open", NULL, 0, NULL);

##### Share on other sites
v0id    122
yeah i just want to know how to pop the drive open, so i can mess with my friends computer

##### Share on other sites
matrix2113    122
You mean like a Trojan?? *tsk tsk*

"I''ve learned something today: It doesn''t matter if you''re white, or if you''re black...the only color that REALLY matters is green"
-Peter Griffin

##### Share on other sites
hehe

'Very funny, Scotty. Now beam down my clothes.' -

[TheBlackJester]

##### Share on other sites
Guest Anonymous Poster
if you are using the Dev-C++ compiler, use this

mciSendString("set cdaudio door open", NULL, 0, NULL);

you can also set the door to close using closed as your option instead of open

p.s.Thanks for this(did not know about it yet in my young programming lifetime)...I got my mother and daughter both with this thinking that they had ran a bug or virus...heehe...

##### Share on other sites
Guest Anonymous Poster
if you are using the Dev-C++ compiler, use this

mciSendStringA("set cdaudio door open", NULL, 0, NULL);

forgot this one up above...the ''A''..sorry for the double-post!

you can also set the door to close using closed as your option instead of open

p.s.Thanks for this(did not know about it yet in my young programming lifetime)...I got my mother and daughter both with this thinking that they had ran a bug or virus...heehe...

##### Share on other sites
Guest Anonymous Poster
Hmmm, is it just my browser, or does something in the sig of BlackJester make the formating of this thread look somewhat weird ?

##### Share on other sites
v0id    122
i always get this when i try to compile it:

--------------------Configuration: CDaudio - Win32 Debug--------------------
Compiling...
open.cpp
Open.obj : error LNK2001: unresolved external symbol __imp__mciSendStringA@16
Debug/Open.exe : fatal error LNK1120: 1 unresolved externals

Open.exe - 2 error(s), 0 warning(s)

##### Share on other sites
Dactylos    122
You have to link to "winmm.lib".

##### Share on other sites
v0id    122
how would that be accomplished?

##### Share on other sites
core    106
Either include winmm.lib in your project, or (if using MSVC) use
#pragma comment(lib,"winmm.lib")

"If people are good only because they fear punishment and hope for reward, then we are a sorry lot indeed." - Albert Einstein