Answer the question
In order to leave comments, you need to log in
How to open and close DVD-RW drive?
Wrote this code
#include <iostream>
#include <windows.h>
#include <shellapi.h>
#include <mmsystem.h>
using namespace std;
int main()
{
MCI_OPEN_PARMS OpenParm;
MCI_SET_PARMS SetParm;
MCIDEVICEID dID;
OpenParm.lpstrDeviceType=L"CDAudio";
mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE, (DWORD_PTR)&OpenParm);
dID = OpenParm.wDeviceID;
mciSendCommand(dID, MCI_SET, MCI_SET_DOOR_OPEN, (DWORD_PTR)&SetParm);
Sleep(3000);
mciSendCommand(dID, MCI_SET, MCI_SET_DOOR_CLOSED, (DWORD_PTR)&SetParm);
mciSendCommand(dID, MCI_CLOSE, MCI_NOTIFY, (DWORD_PTR)&SetParm);
return 0;
}
Answer the question
In order to leave comments, you need to log in
You need to bind to the device not only by its type, but also by the drive letter.
Opening:
mciSendString("open f: type cdaudio alias cd", NULL, 0, NULL);
mciSendString("set cd door open wait", NULL, 0, NULL);
mciSendString("open f: type cdaudio alias cd", NULL, 0, NULL);
mciSendString("set cd door closed wait", NULL, 0, NULL);
Try
OpenParm.lpstrDeviceType = L"F:";
OpenParm.lpstrDeviceType=L"CDAudio";
mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD_PTR)&OpenParm);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question