A real useful piece of code, hence I put it under Z. It does nothing but open and close the door of the CD-ROM player, and pushes the tray in and out. Should your coffee be too hot, you can put it on the moving tray and cool it off! Get the old computer out of the attic, we found a use for it! Seriously, just a quick look at the many things the mciSendString() function can do.
Ze CD-ROM door opener/closer
// use mciSendString() to open and close the CD-ROM door
// you have to link with the winmm.lib file, or
// in the case of Dev-C++ link with libwinmm.a via
// Project>>Project Options>>Parameters>>Add Lib>>libwinmm.a
// a Dev-C++ tested console application by vegaseat 18dec2004
#include <iostream>
#include <windows.h> // Sleep()
#include <mmsystem.h> // mciSendString()
using namespace std; // std::cout, std::cin
int main()
{
mciSendString("open CDAudio", NULL, 0, NULL);
Beep(440,1000);
cout << "Opening CD-ROM door ..." << endl;
mciSendString("set CDAudio door open", NULL, 0, NULL);
cout << "Closing the CD-ROM door in 5 seconds ..." << endl;
Sleep(5000);
mciSendString("set CDAudio door closed", NULL, 0, NULL);
mciSendString("close CDAudio", NULL, 0, NULL);
cin.get(); // wait
return 0;
}
inparanoia 0 Newbie Poster
venomlash 55 Junior Poster
Dukane
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
banders7 1 Newbie Poster
Loke98 0 Newbie Poster
Shft 0 Light Poster
RonalBertogi 46 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.