Solved

Eject CD-ROM

Posted on 2002-07-17
1
525 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 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

729 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