Pascal Scripting: CreateCallback

Prototype:

function CreateCallback(Method: AnyMethod): NativeInt;

Description:

Allows you to perform direct callbacks from DLL functions (like Windows API functions) to functions in your script.

Remarks:

In a 32-bit installer, callback parameters passed by value are not supported when their type is larger than 4 bytes, such as Int64, Double, Extended, and Currency. 64-bit installers have no such limitation.

Example:
function SetTimer(hWnd: HWND; nIDEvent: UINT_PTR; uElapse: UINT; lpTimerFunc: NativeInt): UINT_PTR;
external 'SetTimer@user32.dll stdcall';

var
  TimerCount: Integer;

procedure MyTimerProc(Arg1: HWND; Arg2: UINT; Arg3: UINT_PTR; Arg4: DWORD);
begin
  Inc(TimerCount);
  WizardForm.BeveledLabel.Caption := ' Timer! ' + IntToStr(TimerCount);
  WizardForm.BeveledLabel.Visible := True;
end;

procedure InitializeWizard;
begin
  SetTimer(0, 0, 1000, CreateCallback(@MyTimerProc));
end;