Link to home
Start Free TrialLog in
Avatar of SkizoWalker
SkizoWalker

asked on

Detecting CD Changes

Hi .. right now programming an API which playing CD through MCI device in C++ (using MFC)
Two questions in one :

-How could i detected the CD has been manually ejected , or inserted ? (i need a full source description please)
-What is the xorrect sentence to the mciCommandMsg to Ecjet a CD Track ?

Hope to catch an answer ASAP

Greetings .. Skiwoka
ASKER CERTIFIED SOLUTION
Avatar of tma050898
tma050898
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SkizoWalker,

In order to open and close the cd drawer...

Step 1:
add include of "mmsystem.h"

Step 2:
add import library
winmm.lib

Step 3:
add following code

MCI_OPEN_PARMS OpenParms;
OpenParms.lpstrDeviceType = (LPCSTR) MCI_DEVTYPE_CD_AUDIO;
OpenParms.wDeviceID = 0;

// open device
if (!mciSendCommand (NULL, MCI_OPEN, MCI_WAIT |
 MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID | MCI_OPEN_SHAREABLE,
 (DWORD)(LPVOID) &OpenParms))
{
 // open drawer
 mciSendCommand (OpenParms.wDeviceID,
  MCI_SET, MCI_SET_DOOR_OPEN, NULL);

 AfxMessageBox(_T("Press OK to close the CD drawer"));

 // close drawer
 mciSendCommand (OpenParms.wDeviceID,
  MCI_SET, MCI_SET_DOOR_CLOSED, NULL);

 // close device
 mciSendCommand (OpenParms.wDeviceID,
  MCI_CLOSE, MCI_WAIT, NULL);
}

I don't know, however, how to detect when the cd drawer has been opened manually.

Tom

HOWTO: Getting Notification of CD-ROM Insertion or Removal
http://support.microsoft.com/support/kb/articles/q163/5/03.asp
Avatar of SkizoWalker
SkizoWalker

ASKER

okay thanx for all answer people
I have anyway find myselft the wayt to Open and close the CD drawer and to check CDRom insertion/Removal .. i just launch a SetTimer procedure of 1200 ms interval , while i check if i have an eror frommy mci device (if an error occured , so -> no disk present) and if no error , then get the new Track status
 
Anyway here are the points

thx also chensu

Greetings , Skiwoka
France