Name
Dispinterface Keyword
Syntax
typeName= dispinterface ['{Guid...}']Method and property declarations... end;
Description
The
dispinterface keyword is similar to
interface for declaring an interface type, but it
declares a dispatch interface. Delphi uses a dispatch interface to
access a COM automation server through the Invoke
method of the IDispatch interface. A class cannot
implement a dispatch interface, nor can a dispatch interface inherit
from another interface (dispatch or normal).
Declarations can specify a dispatch identifier with the
dispid directive. All the dispatch identifiers
within a single dispinterface must be unique. No
other method directives are allowed.
Property declarations do not include read or
write specifiers. By default a property has read
and write access, or you can declare the property with the
readonly or writeonly
directive. An array property can have a default
directive. No other property directives are
allowed.
Tips and Tricks
The purpose of a
dispinterfacedeclaration is to make a dispatch interface available at compile time, so you don’t have to wait until runtime to learn you misspelled a method name. The author of the COM server must provide thedispinterfacedeclaration for the COM object. If you have a type library, you can use Delphi’s type library editor to generate the source code anddispinterfacedeclaration.A COM server can implement an ordinary interface, a dispatch interface, or both. Check the type library to learn what kind of interface ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access