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

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.

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.