dual

[uuid, oleautomation, dual [, optional-attribute-list]]
interface
interfacename
{ . . .};

Example

[uuid(. . .), oleautomation, dual]

    interface IHello : Idispatch

   

     //diverse and sundry properties and methods defined here

    };

 

Remarks

The dual attribute identifies an interface that exposes properties and methods through IDispatch and directly through the VTBL. The interface must be compatible with OLE Automation and be derived from IDispatch. The attribute is not allowed on dispinterfaces.

The dual attribute creates an interface that is both a Dispatch interface and a Component Object Model (COM) interface. The first seven entries of the VTBL for a dual interface are the seven members of IDispatch, and the remaining entries are OLE COM entries for direct access to members of the dual interface. All the parameters and return types specified for members of a dual interface must be OLE Automation-compatible types.

All members of a dual interface must pass an HRESULT as the function return value. Members, such as property accessor functions, that need to return other values, such as  should specify the last parameter as [out, retvalE_IXBP], indicating an output parameter that returns the value of the function. In addition, members that need to support multiple locales should pass an lcid3KQO.S8 parameter.

A dual interface provides for both the speed of direct VTBL binding and the flexibility of IDispatch binding. For this reason, dual interfaces are recommended whenever possible.

 

Note  If your application accesses object data by casting the this pointer within the interface call, you should check the VTBL pointers in the object against your own VTBL pointers to ensure that you are connected to the appropriate proxy.

 

Specifying dual on an interface implies that the interface is compatible with OLE Automation, and therefore causes both the TYPEFLAG_FDUAL and TYPEFLAG_FOLEAUTOMATION flags to be set.

Flags

TYPEFLAG_FDUAL, TYPEFLAG_FOLEAUTOMATION

See Also

interface, oleautomation, ODL File Syntax, ODL File Example, Generating a Type Library With MIDL