Name

Dispinterface Keyword

Syntax

type Name = 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 dispinterface declaration 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 the dispinterface declaration for the COM object. If you have a type library, you can use Delphi’s type library editor to generate the source code and dispinterface declaration.

  • A COM server can implement an ordinary interface, a dispatch interface, or both. Check the type library to learn what kind of interface ...

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.