Creates a user-defined DLL Callback function.
DllCallbackRegister ( "function", "return type", "params" )
Parameters
| function | The name of the User Defined Function to call. |
| return type | The return type and calling convention of the function (see DllCall). |
| params | A semi-colon separated list of parameters that will be passed to this function. Uses DllCall types. |
Return Value
| Success: | Returns a dll "handle" to be used with DllCallbackGetPtr and DllCallbackFree functions. |
| Failure: | Returns 0 if error occurs. |
Remarks
When finished working with a callback, call the DllCallbackFree function to close it. AutoIt normally closes all files upon termination, but explicitly calling DllCallbackFree is still a good idea.
Related
DllCall, DllCallbackFree, DllCallbackGetPtr
Example
; Create callback function
$handle = DLLCallbackRegister ("_EnumWindowsProc", "int", "hwnd;lparam")
; Call EnumWindows
DllCall("user32.dll", "int", "EnumWindows", "ptr", DllCallbackGetPtr($handle), "lparam", 10)
; Delete callback function
DllCallbackFree($handle)
; Callback Procedure
Func _EnumWindowsProc($hWnd, $lParam)
If WinGetTitle($hWnd) <> "" And BitAnd(WinGetState($hWnd), 2) Then
$res = MsgBox(1, WinGetTitle($hWnd), "$hWnd=" & $hWnd & @CRLF & "lParam=" & $lParam & @CRLF & "$hWnd(type)=" & VarGetType($hWnd))
If $res = 2 Then Return 0 ; Cancel clicked, return 0 to stop enumeration
EndIf
Return 1 ; Return 1 to continue enumeration
EndFunc