dual attribute

The dual attribute identifies an interface that exposes properties and methods through IDispatch and directly through the VTBL.

[
    uuid(uuid-number), 
    oleautomation,
    dual 
  [ , optional-attribute-list]
]
interface interface-name
{
    . . .
};

Parameters

uuid-number

Specifies a universally unique identification number for the interface

optional-attribute-list

Specifies a list of zero or more additional MIDL attributes.

interface-name

The name of the interface to which the dual attribute will be applied.

Remarks

Interfaces identified by the dual attribute must be compatible with Automation and be derived from IDispatch. This attribute is not allowed on dispinterfaces.

The dual attribute creates an interface that is both an IDispatch 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 for direct access to members of the dual interface. All the parameters and return types specified for members of a dual interface must be 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, should specify the last parameter as out, retval, indicating an output parameter that returns the value of the function. In addition, members that need to support multiple locales should pass an lcid 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 Automation, and therefore causes both the TYPEFLAG_FDUAL and TYPEFLAG_FOLEAUTOMATION flags to be set.

Flags

TYPEFLAG_FDUAL, TYPEFLAG_FOLEAUTOMATION

Examples

[
    uuid(1e196b20-1f3c-1069-996b-00dd010fe676), 
    oleautomation, dual
]
interface IHello : IDispatch
{
    //Diverse properties and methods defined here.
};

See also

Generating a Type Library With MIDL

interface

lcid

oleautomation

ODL File Syntax

ODL File Example

out

retval