Solved

Eject CD-ROM

Posted on 2002-07-17
1
488 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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Powershell based monitoring system 2 126
Error on moodle after upgrade 3 105
scoreUp challenge 14 47
Thin secure Windows 10 5 46
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 …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

7 Experts available now in Live!

Get 1:1 Help Now