driver for ejecting cd/dvd drive

I am planning to make a driver for ejecting cd/dvd drive in computer with c++/c programming language.
But, frankly telling , I have just the knowledge of c/c++ , but no clue how to start making the driver.
Please, guide me through it and the things I need to study .
Please, if possible post the link which may be helpful to me.
Last edited on
closed account (13bSLyTq)
Hi,

It actually unnecessary to go all the way to develop a driver, when you can just do:

1
2
3
4
5
6
7
8
9
10
11
12
13
#pragma comment(lib,"Winmm.lib")
#include <iostream>
#include <windows.h> 
#include <mmsystem.h>

using namespace std;

int main()
{
mciSendString("open CDAudio", NULL, 0, NULL);
mciSendString("set CDAudio door open", NULL, 0, NULL);
return 0;
}
Last edited on
it's showing the following errors: 1)default.cpp:(.text+0x28): undefined reference to `__imp_mciSendStringA'
2) c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe final link failed: Invalid operation
3)C:\Users\sanyam gupta\Desktop\collect2.exe [Error] ld returned 1 exit status

and please explain me the logic !
thanks
You are obviously using MinGW, so you need to specify -lwinmm on the command line options (or link to winmm with your IDE), because the #pragma way of linking only works with MSVC.
I am using devc++ compiler for them!
Should I use microsoft visual studio . ? would that be fine ?
And Frankly telling , I dont know what is MinGW , MSVC ?
Can you please me more about it ?
MinGW is a compiler based of GCC. Dev C++ comes with MinGW, as can be seen in your command line of errors:
c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe


MSVC is MicroSoft Visual C, its the compiler that comes with microsoft visual studio. It is another option for a compiler. It is generally agreed that if you are building applications for Windows, it is good to use Microsoft visual studio (though not necessary), due to the various options it gives for decreasing development time, and the fact that it will definitely provide anything.

Anyone, to add the -lwinmm line to your command line on Dev-C++, you can do something like open your project, goto "Project Settings", find the link options setting. This should be in one of the tabs. Just add "-lwinmm" to that. Sorry if this isn't very descriptive, I don't actually have Dev-C++ on me at the moment (and I haven't used it for years).
Nt3 , how you do programming then ? what do you use /.?
Various things. On Windows, I most commonly use Code::Blocks (see http://www.codeblocks.org/ ), or the command line and Cygwin tools. On Linux, I use Vi, and I don't use Max :). I do occasionally use Microsoft Visual 2010 Express for the functions and structures that MinGW doesn't provide, but apart from that, mostly Code::Blocks.
oh great :) , so codeblocks ! i use too :)
Topic archived. No new replies allowed.