Solved

MCI: how to determine CDaudio drive door status

Posted on 1998-07-16
6
331 Views
Last Modified: 2013-12-03
I know MCI CDAudio device handling quite well, but I still don't know how to determine wether the CD-ROM drive door is open or closed, in order to distinguish when I have to call MCI_Set_Door_Closed instead of MCI_Set_Door_Open.
0
Comment
Question by:mauromol
  • 3
  • 2
6 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 200 total points
ID: 1410340
You may need to do some experiments.

Try using the MCI_STATUS command with the flags MCI_STATUS_READY or MCI_STATUS_MEDIA_PRESENT. This may not meet your requirements. Then, you can get the notification of CD-ROM insertion or removal. See the following KB article.
HOWTO: Getting Notification of CD-ROM Insertion or Removal  
http://support.microsoft.com/support/kb/articles/q163/5/03.asp
0
 

Expert Comment

by:overworked
ID: 1410341
MCI_STATUS_PARMS status;
status.dwitem = MCI_STATUS_MODE;

mciSendCommand(deviceid,MCI_STATUS,MCI_WAIT | MCI_STATUS_ITEM,*status);

if(status.dwReturn == MCI_MODE_OPEN
    The door is open
else
    The door is closed


I do this for my cd player to determine whether my eject button should send a MCI_SET_DOOR_CLOSED or _OPEN command.
0
 

Author Comment

by:mauromol
ID: 1410342
To overworked: this does not work, sorry. MCI_Mode_Open is returned both when the door is open and when the door is closed but the drive is empty.
0
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.

 

Author Comment

by:mauromol
ID: 1410343
To chensu: I had a look to the link you gave me: thank you!
I would have only a question: Microsoft says that the Device Type should be a dbt_DevTyp_Volume, but when I intercept wm_DeviceChange, dbch_DeviceType seems to be set to dbt_DevTyp_OEM. Why?
Delphi doesn't define dbt constants: I use explicit numbers for that (dbt_DeviceArrival = $8000, where $ means hex number; dbt_DeviceRemoveComplete = $8004; dbt_DevTyp_Volume = $2), but both dbt_DeviceArrival and dbt_DeviceRemoveComplete return $0 (that should be dbt_DevTyp_OEM, shouldn't it?) instead of $2. Maybe you know where the problem is?
0
 
LVL 23

Expert Comment

by:chensu
ID: 1410344
On my computer, dbch_devicetype is DBT_DEVTYP_VOLUME. Check it carefully. And, try it on other computers.
0
 

Author Comment

by:mauromol
ID: 1410345
Ok, I got it to work, thank you!
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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
A short film showing how OnPage and Connectwise integration works.

930 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

10 Experts available now in Live!

Get 1:1 Help Now