From RAD Studio API Documentation
Jump to: navigation, search


function Invoke(CodeAddress: Pointer; const Args: TArray<TValue>;
CallingConvention: TCallConv; AResultType: PTypeInfo; IsStatic: Boolean; IsConstructor: Boolean): TValue;


extern DELPHI_PACKAGE TValue __fastcall Invoke(void * CodeAddress, const System::DynamicArray<TValue> Args, System::Typinfo::TCallConv CallingConvention, System::Typinfo::PTypeInfo AResultType, bool IsStatic = false, bool IsConstructor = false);


Type Visibility Source Unit Parent
function public
System.Rtti System.Rtti


Dynamically invokes a method.

Use Invoke to invoke a method at run time. Invoke is useful when the actual method is not known at compile time, but is rather looked up at run time.

The following table lists the parameters of the Invoke routine.

Parameter Description


The address of the method to invoke.


An array of TValue records, each storing a parameter passed to the method.


The calling convention used to invoke the method.


The type information of the method result type.

Invoke returns a TValue record that holds the result of the invoked method.

Depending on the type of the invoked method, the Args array must follow a set of rules:

  • For instance methods, the first element in the Args array must be the pointer to the instance.
  • For interface methods, the first element in the Args array must be the interface reference.
  • For class methods, the first element in the Args array must be the a class reference.
  • Static methods and global routines do not require any special treatment.

See Also