Solved

MCI: how to determine CDaudio drive door status

Posted on 1998-07-16
6
342 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

830 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