本帖最后由 netegg 于 2011-1-11 16:30 编辑
这也买呀,apiex里现成的函数#include <WinAPIEx.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
Global $iMemo
_Main()
Func _Main()
Local $Drive = DriveGetDrive('CDROM'), $hGUI
; Create GUI
$hGUI = GUICreate("CD Tray", 400, 300)
; Create memo control
$iMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
GUISetState()
If IsArray($Drive) Then
MemoWrite('Open...')
_WinAPI_EjectMedia($Drive[1])
MemoWrite('Tray is open: ' & _WinAPI_IsDoorOpen($Drive[1]))
Sleep(1000)
MemoWrite('Close...')
_WinAPI_LoadMedia($Drive[1])
MemoWrite('Tray is open: ' & _WinAPI_IsDoorOpen($Drive[1]))
EndIf
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>_Main
; Write message to memo
Func MemoWrite($sMessage = "")
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite
|