Solved

Eject CD-ROM

Posted on 2002-07-17
1
493 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
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 30 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Running shell command from Access 3 69
Generic progress indicator 6 113
maven archtype selection in eclipse 1 53
Message not shown 5 34
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now