How can I open my DVD-RW in C++?

Does anybody know how can I open the DVD-RW door in C++? What libraries I have do find? Or what headers I have to use? I found something on the net and it says that in mmsystem.h header are some functions that can help me on solving that problem but I thought that I have to ask somebody about it. Thanks.
Last edited on
Last edited on
Actually the problem is not solved because I can't understand those things.
I tried something:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include<windows.h>
#include<mmsystem.h>
#include<iostream>
using namespace std;
MCIERROR mciSendString(
  LPCTSTR lpszCommand,
  LPTSTR lpszReturnString,
  UINT cchReturn,
  HANDLE hwndCallback
);
_stprintf_s(
  lpszCommand,
  TEXT("set %s %s %s"),
  lpszDeviceID,
  "door open",
  lpszFlags
);

int main()
{

    mciSendString(_stprintf_s, NULL, 0, NULL);
   
    return (0);
}


The first parameter of mciSendString must do the job, I think. I searched the "set" command and there it says that " lpszCommand" must be set with
1
2
3
4
5
6
7
_stprintf_s(
  lpszCommand,
  TEXT("set %s %s %s"),
  lpszDeviceID,
  "door open",
  lpszFlags
);

I don't understand. Please help me with some explanations.
1
2
3
4
5
6
7
8
9
#include <Windows.h>

#pragma comment(lib, "Winmm.lib")

int main(){
   mciSendString ("open cdaudio", 0, 0, 0);
   mciSendString ("set cdaudio door open", 0, 0, 0);
   mciSendString ("close cdaudio", 0, 0, 0);
}
Works. Note that pragma is something specific to VC++. It simply says that you're using that library. If you don't use VC++, remove line 3 and add Winmm.lib to the list of your dependencies.
Last edited on
I understand. The thing is that I haven't VC++. Is totaly my bad. I don't want to be nasty but I really want to do that program. Can you tell me just where to find that library? I searched on microsoft.com but it don't give me any results. I also searched on google but the same thing. I have Code::Blocks with MinGW. Thanks.
Mingw DOES came with libwinmm.a (this is what you need), at least if you use latest distribution from http://tdragon.net/recentgcc/
And if I download the MinGW from the link below, what I have to do? Just to put into there the hamsterman's code below?
Just change the path in Settings/Compiler and Debugger/Global Compiler Settings/Toolchain Executables to wherever you installed the new MinGW.
You don't need the latest version just to use winmm, though.

To link the library, add "winmm" to Project/Build options/Linker settings/Link libraries.
Last edited on
Thanks guys! You have really helped me.
Topic archived. No new replies allowed.