DllCallbackRegister
创建自定义 DLL 回调函数.
DllCallbackRegister ( "function", "return type", "params" )
参数
function
|
用户自定义函数的名称.
|
return type
|
函数的返回类型和调用约定 (见 DllCall).
|
params
|
分号分隔的、将被传递到函数的参数列表. 见备注.
|
返回值
备注
除 "struct" 之外全部使用 DllCall() 类型.
当完成一个回调, 调用 DllCallbackFree() 函数将其关闭.
通常 AutoIt 终止后会关闭所有文件, 但还是推荐调用 DllCallbackFree().
相关
DllCall, DllCallbackFree, DllCallbackGetPtr
函数示例
#include <MsgBoxConstants.au3>
; Create callback function.
Local $hHandle = DllCallbackRegister("_EnumWindowsProc", "int", "hwnd;lparam")
; Call EnumWindows.
DllCall("user32.dll", "int", "EnumWindows", "ptr", DllCallbackGetPtr($hHandle), "lparam", 10)
; Delete callback function.
DllCallbackFree($hHandle)
; Callback Procedure
Func _EnumWindowsProc($hWnd, $lParam)
; If the Title is empty or if the window is not visible then continue enumeration.
If WinGetTitle($hWnd) = "" Or BitAND(WinGetState($hWnd), 2) = 0 Then Return 1
Local $iRes = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), _
WinGetTitle($hWnd), "$hWnd=" & $hWnd & @CRLF & _
"$lParam=" & $lParam & @CRLF & _
"$hWnd(type)=" & VarGetType($hWnd))
If $iRes <> $IDOK Then Return 0 ; Cancel/Close button clicked, return 0 to stop enumeration.
Return 1 ; Return 1 to continue enumeration.
EndFunc ;==>_EnumWindowsProc
----------------------------------------
|