Name
VarDispProc Variable
Syntax
var VarDispProc: Pointer; procedureInvoke
(Result: PVariant; const Instance: Variant; CallDesc: PCallDesc; Params: Pointer); cdecl; VarDispProc := @Invoke
;
Description
VarDispProc
points to a procedure that invokes an
IDispatch
method from a Variant
reference. When a Variant
refers to a COM server,
it is actually storing an IDispatch
interface and
has the VarType
of varDispatch
.
When your program calls a method or uses a property of the COM
server, the Variant
object must call the
IDispatch.Invoke
method. Delphi relies on the
VarDispProc
procedure to do
this.
Result
is a pointer to a
Variant
where a function result should be stored,
or it is nil
if no result is expected.
Instance
is the Variant
that
contains the IDispatch
interface invoking the
method or property. CallDesc
points to a record
that describes the method to be invoked, and
Params
points to an array that describes the
method arguments.
Tips and Tricks
Do not assign
nil
toVarDispProc
. Unlike similar procedure pointers in Delphi, ifVarDispProc
isnil
, Delphi does not have a default behavior, and you get an access violation instead.The initial value of
VarDispProc
points to a procedure that reports runtime error 17 (EVariantError
).The
ComObj
unit defines this procedure to handle all the details for you. It also declares thePCallDesc
type.
See Also
DispCallByIDProc Variable, Dispinterface Keyword, IDispatch Interface, Interface Keyword, OleVariant Type, Variant Type |
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.