StdCall Directive
The stdcall
directive uses the Windows standard
calling convention: arguments are pushed onto the stack, starting
with the rightmost argument. The subroutine is responsible for
popping the arguments from the stack.
Functions return ordinal values, pointers, and small records or sets
in EAX
and floating-point values on the FPU stack.
Strings, dynamic arrays, Variant
s, and large
records and sets are passed as a hidden var
parameter. This hidden parameter is the last parameter, so it is
pushed first onto the stack. If the subroutine is a method,
Self
is pushed just before the function’s
var
result (if one is needed).
// Make a list of all the top-level windows.
function Callback(Handle: HWND; List: TStrings): LongBool; stdcall;
var
Caption: array[0..256] of Char;
Len: Integer;
Text: string;
begin
Len := GetWindowText(Handle, Caption, SizeOf(Caption)-1);
SetString(Text, Caption, Len);
List.Add(Text);
Result := True;
end;
...
EnumWindows(@Callback, LParam(ListBox1.Items));