Quick start manual
Object interfaces
10-11
Automation objects (Windows only)
An interface query returns nil if object is nil. Otherwise, it passes the GUID of interface
to the QueryInterface method in object, raising an exception unless QueryInterface
returns zero. If QueryInterface returns zero (indicating that object’s class implements
interface), the interface query returns an interface reference to object.
Automation objects (Windows only)
An object whose class implements the IDispatch interface (declared in the System unit)
is an Automation object. Automation is available on Windows only.
Dispatch interface types (Windows only)
Dispatch interface types define the methods and properties that an Automation
object implements through IDispatch. Calls to methods of a dispatch interface are
routed through IDispatch’s Invoke method at runtime; a class cannot implement a
dispatch interface.
A dispatch interface type declaration has the form
type interfaceName = dispinterface
['{GUID}']
memberList
end;
where ['{GUID}'] is optional and memberList consists of property and method
declarations. Dispatch interface declarations are similar to regular interface
declarations, but they cannot specify an ancestor. For example,
type
IStringsDisp = dispinterface
['{EE05DFE2-5549-11D0-9EA9-0020AF3D82DA}']
property ControlDefault[Index: Integer]: OleVariant dispid 0; default;
function Count: Integer; dispid 1;
property Item[Index: Integer]: OleVariant dispid 2;
procedure Remove(Index: Integer); dispid 3;
procedure Clear; dispid 4;
function Add(Item: OleVariant): Integer; dispid 5;
function _NewEnum: IUnknown; dispid -4;
end;
Dispatch interface methods (Windows only)
Methods of a dispatch interface are prototypes for calls to the Invoke method of the
underlying IDispatch implementation. To specify an Automation dispatch ID for a
method, include the dispid directive in its declaration, followed by an integer
constant; specifying an already used ID causes an error.
A method declared in a dispatch interface cannot contain directives other than
dispid. Parameter and result types must be automatable—that is, they must be Byte,
Currency, Real, Double, Longint, Integer, Single, Smallint, AnsiString, WideString,
TDateTime, Variant, OleVariant, WordBool, or any interface type.