?
Solved

Eject CD-ROM

Posted on 2002-07-17
1
Medium Priority
?
533 Views
Last Modified: 2013-11-20
Hello,

Does anybody know the command that is used in VC++ to eject the CD-ROM?

Thank you all
0
Comment
Question by:Mazen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 90 total points
ID: 7159691
See http://www.codeguru.com/system/cdr.html

//Open or Close CD Drive
//cDrive is Drive Letter to Open, or 0x01 for 'Default' drive
//Examples:
//CD_OpenCloseDrive(TRUE, 'G');  //Open CD Door for Drive G:
//CD_OpenCloseDrive(FALSE, 'G'); //Close CD Door for Drive G:
//CD_OpenCloseDrive(TRUE, 1);    //Open First Logical CD Door
void CD_OpenCloseDrive(BOOL bOpenDrive, TCHAR cDrive)
{
MCI_OPEN_PARMS op;
MCI_STATUS_PARMS st;
DWORD flags;

TCHAR szDriveName[4];
strcpy(szDriveName, "X:");

::ZeroMemory(&op, sizeof(MCI_OPEN_PARMS));
op.lpstrDeviceType = (LPCSTR) MCI_DEVTYPE_CD_AUDIO;

if(cDrive > 1)
{
 szDriveName[0] = cDrive;
 op.lpstrElementName = szDriveName;
 flags = MCI_OPEN_TYPE
       | MCI_OPEN_TYPE_ID
       | MCI_OPEN_ELEMENT
       | MCI_OPEN_SHAREABLE;
}
else flags = MCI_OPEN_TYPE
           | MCI_OPEN_TYPE_ID
           | MCI_OPEN_SHAREABLE;

if (!mciSendCommand(0,MCI_OPEN,flags,(unsigned long)&op))
{
 st.dwItem = MCI_STATUS_READY;

 if(bOpenDrive)
  mciSendCommand(op.wDeviceID,MCI_SET,MCI_SET_DOOR_OPEN,0);
 else
  mciSendCommand(op.wDeviceID,MCI_SET,MCI_SET_DOOR_CLOSED,0);

 mciSendCommand(op.wDeviceID,MCI_CLOSE,MCI_WAIT,0);
}
}
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question