Accessing Automation Objects
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.
Dostları ilə paylaş: