0

can any one give c++ program to eject cd from cd-rom,
i am getting error in this program please solve this

// 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;  
}

Edited by Nick Evan: Added code-tags

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Ancient Dragon
0

add #pragma comment(lib,"Winmm.lib") somewhere in your *.cpp program, preferably before main()

BTW the program works ok on my computer -- 64-bit Windows 7.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.