Check CD-ROM Tray Status

后端 未结 2 2004
野的像风
野的像风 2021-01-14 20:25

I have written a small piece of code to open/close a cd/dvd drive tray using the DeviceIoControl API and the proper IOCTL but I don\'t seem to be able to check the tray stat

相关标签:
2条回答
  • 2021-01-14 20:54

    Well, the documentation for this API states that it returns whether there is a disk in the drive and nothing about whether the tray is open or not. The specific requirements as to which error code is returns is not documented. I get 21 in both situations too.

    I reviewed the documentation and could not find any documented way to do what you asked. To most applications, whether or not the tray is open is not that interesting.

    0 讨论(0)
  • 2021-01-14 21:08

    I could not find a way to read the status of the drive tray. Instead I'm checking the time it takes to execute the eject command as explain there, if it take more than 100ms for the eject to return I'm assuming we actually did eject the media. If the eject command completes too fast am then assuming the tray is opened and needs to be closed. It seems to do the trick to implement an open/close toggle function. Time will tell :)

    0 讨论(0)
提交回复
热议问题