By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,661 Members | 781 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,661 IT Pros & Developers. It's quick & easy.

prototype for mciSendString,sleep,beep

P: 1
prototype for mciSendString,sleep,beep. unable to open include windows.h,mmsystem.h error. is this syntax correct using namespace std;

#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);
cout << "Opening CD-ROM door ..." << endl;
mciSendString("set CDAudio door open", NULL, 0, NULL);

cout << "Closing the CD-ROM door in 5 seconds ..." << endl;
mciSendString("set CDAudio door closed", NULL, 0, NULL);

mciSendString("close CDAudio", NULL, 0, NULL);

cin.get(); // wait
return 0;
Nov 6 '10 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,197
This is a code error:

Expand|Select|Wrap|Line Numbers
  1. #include <windows.h> // Sleep() 
  2. #include <mmsystem.h> // mciSendString()
There is no // Sleep() precompiler directive.

Lines beginning with # are precompiler only. You can't add stuff like comments. Everything on those # lines must be valid precompiler code.
Nov 7 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.