DLL Example: Passing Procedure Parameters by Value for Callback Function |
Version 5 |
You can pass ATEasy or DLL procedure as a callback function to a DLL procedure. When passing an ATEasy procedure as a Val Param to a DLL procedure, ATEasy interprets as a callback function and processes accordingly. However ATEasy has no way of checking the function's validity. Thus the user is responsible for checking to follow exactly the definition of callback function.
The following example shows this examples:
First, this is DLL (User32.dll) procedure:
DLL Procedures
Procedure EnumWindows(procCallback,
lParam): Bool
procCallback: Val Procedure
lParam: Val Long
Second, in Submodule Procedures
the following two procedures are defined:
Procedure Test_Callback():
Void
bSuccess: Bool
{
! Test_Callback -- Call Windows EnumWindows with ATEasy
callback function
bSuccess=User32.EnumWindows(EnumWindowsCallbackFunction,
0x090A0B0C)
}
Procedure EnumWindowsCallbackFunction(hwnd,
lparam): Bool
hwnd: Val AHandle
lparam: Val Long
{
! ... add code ...
return True
}