Dual Interfaces

From RAD Studio
Jump to: navigation, search

Go Up to Automation Interfaces

A dual interface is a custom interface and a dispinterface at the same time. It is implemented as a COM VTable interface that derives from IDispatch. For those controllers that can access the object only at run time, the dispinterface is available. For objects that can take advantage of compile-time binding, the more efficient VTable interface is used.

Dual interfaces offer the following combined advantages of VTable interfaces and dispinterfaces:

  • For VTable interfaces, the compiler performs type checking and provides more informative error messages.
  • For Automation controllers that cannot obtain type information, the dispinterface provides runtime access to the object.
  • For in-process servers, you have the benefit of fast access through VTable interfaces.
  • For out-of-process servers, COM marshals data for both VTable interfaces and dispinterfaces. COM provides a generic proxy/stub implementation that can marshal the interface based on the information contained in a type library.

The first three entries of the VTable for a dual interface refer to the IUnknown interface, the next four entries refer to the IDispatch interface, and the remaining entries are COM entries for direct access to members of the custom interface.