检查光驱托盘的开/关状态.
#Include <WinAPIEx.au3>
_WinAPI_IsDoorOpen ( $sDrive )
$sDrive | CD 盘驱动器号, 如 D:, E:, 等等. |
成功: | 返回 1 - CD (DVD) 托盘打开. |
返回 0 - 未打开. | |
失败: | 返回 0,并设置@error标志为非 0 值. |
在MSDN中搜索
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global $Drive = DriveGetDrive('CDROM')
If IsArray($Drive) Then
ConsoleWrite('Open...' & @CR)
_WinAPI_EjectMedia($Drive[1])
ConsoleWrite('Tray is open: ' & _WinAPI_IsDoorOpen($Drive[1]) & @CR)
Sleep(1000)
ConsoleWrite('Close...' & @CR)
_WinAPI_LoadMedia($Drive[1])
ConsoleWrite('Tray is open: ' & _WinAPI_IsDoorOpen($Drive[1]) & @CR)
EndIf