Ejects media from a device
#include <WinAPIFiles.au3>
_WinAPI_EjectMedia ( $sDrive )
$sDrive | The drive letter of the CD tray to eject, in the format D:, E:, etc. |
Success: | 1. |
Failure: | 0 and sets the @error flag to non-zero. |
Search IOCTL_STORAGE_EJECT_MEDIA in MSDN Library.
#include <WinAPIFiles.au3>
Local $aDrive = DriveGetDrive('CDROM')
If IsArray($aDrive) Then
ConsoleWrite('Open...' & @CRLF)
_WinAPI_EjectMedia($aDrive[1])
ConsoleWrite('Tray is open: ' & _WinAPI_IsDoorOpen($aDrive[1]) & @CRLF)
Sleep(1000)
ConsoleWrite('Close...' & @CRLF)
_WinAPI_LoadMedia($aDrive[1])
ConsoleWrite('Tray is open: ' & _WinAPI_IsDoorOpen($aDrive[1]) & @CRLF)
EndIf