Quick start manual
10-12
Delphi Language Guide
Automation objects (Windows only)
Dispatch interface properties
Properties of a dispatch interface do not include access specifiers. They can be 
declared as read only or write only. To specify a dispatch ID for a property, include 
the dispid directive in its declaration, followed by an integer constant; specifying an 
already used ID causes an error. Array properties can be declared as default. No 
other directives are allowed in dispatch-interface property declarations.
Accessing Automation objects (Windows only)
Use variants to access Automation objects. When a variant references an Automation 
object, you can call the object’s methods and read or write to its properties through 
the variant. To do this, you must include ComObj in the uses clause of one of your 
units or your program or library.
Automation object method calls are bound at runtime and require no previous 
method declarations. The validity of these calls is not checked at compile time.
The following example illustrates Automation method calls. The CreateOleObject 
function (defined in ComObj) returns an IDispatch reference to an Automation object 
and is assignment-compatible with the variant Word.
var
Word: Variant;
begin
Word := CreateOleObject('Word.Basic');
Word.FileNew('Normal');
Word.Insert('This is the first line'#13);
Word.Insert('This is the second line'#13);
Word.FileSaveAs('c:\temp\test.txt', 3);
end;
You can pass interface-type parameters to Automation methods.
Variant arrays with an element type of varByte are the preferred method of passing 
binary data between Automation controllers and servers. Such arrays are subject to 
no translation of their data, and can be efficiently accessed using the VarArrayLock 
and VarArrayUnlock routines.
Automation object method-call syntax
The syntax of an Automation object method call or property access is similar to that 
of a normal method call or property access. Automation method calls, however, can 
use both positional and named parameters. (But some Automation servers do not 
support named parameters.)
A positional parameter is simply an expression. A named parameter consists of a 
parameter identifier, followed by the := symbol, followed by an expression. 
Positional parameters must precede any named parameters in a method call. Named 
parameters can be specified in any order.










