• 0

Check status of a CD tray [C++]


Question

I found sample code and was able to get a drive to eject or load, but what I really need the program to do is perform the operation based on the drive's current state. i'm using the DeviceIoControl function to send commands to my device. The problem i'm having is I don't know which command to send to get status info back for the tray.

the DeviceIoControl function is defined in winioctl.h

for alittle more detail, i'm trying to make an app that will eject/load a drive based on its state. For now this app is just going to run once and terminate. In the end, I want it to sit in the system tray or run in the background and check for a certain keypress to execute the load/eject function. My idea behind this is the F12 button in OS X that ejects a CD if you hold the button for afew seconds.

If there is an easier way of doing this, please let me know!

thanks :D

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

You can get this status by sending a raw SCSI command. You should check the mmc specs (from t10.org drafts), and look at GET EVENT STATUS NOTIFICATION or MECHANISM STATUS. To send a raw command, you need to use IOCTL_SCSI_PASS_THROUGH_DIRECT.

Link to comment
Share on other sites

  • 0
You can get this status by sending a raw SCSI command. You should check the mmc specs (from t10.org drafts), and look at GET EVENT STATUS NOTIFICATION or MECHANISM STATUS. To send a raw command, you need to use IOCTL_SCSI_PASS_THROUGH_DIRECT.

584718130[/snapback]

That seems alittle more complex than I want to get into, this is supposed to be a simple app. Unless you provide me with some sample code for getting the status.

anyone know some easier ways of going about this?

Link to comment
Share on other sites

  • 0
no one has done any work manipulating HDs or CD trays?

584723237[/snapback]

It probably isn't that hard. If I get some time this weekend, I'll work it up for you.

If all you're trying to do is emulate the F12 of OS X, then I'd recommend using the Windows multimedia library. You can get status with the MCI_STATUS command, using mciSendCommand. You can also open and close CD doors with the mciSendString command.

Link to comment
Share on other sites

  • 0

You could try calling an eject and then load command asynchronously. If the tray is closed, it would eject and the firmware might ignore the quick load command. If the tray is open, sending eject first would cause the firmware to probably skip it quickly and allow the second load command.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.