oleautomation attribute

The oleautomation attribute indicates that an interface is compatible with Automation.

    [ , interface-attribute-list] 
interface interface-name : base-interface



Specifies a UUID string generated by the Uuidgen utility.


Specifies other attributes that apply to the interface as a whole.


Specifies the name of the interface.


Specifies the name of an Automation interface from which this derived interface inherits member functions, status codes, and interface attributes. All Automation interfaces are derived from IUnknown or IDispatch.


The parameters and return types specified for the members of an [oleautomation] interface must be Automation-compatible, as listed in the following table.

Type Description
boolean Data item that can have the value VARIANT_TRUE or VARIANT_FALSE. The size corresponds to VARIANT_BOOL.
unsigned char 8-bit unsigned data item.
double 64-bit IEEE floating-point number.
float 32-bit IEEE floating-point number.
int Signed integer, whose size is system dependent. On 32-bit platforms, MIDL treats int as a 32-bit signed integer.
long 32-bit signed integer.
short 16-bit signed integer.
BSTR Length-prefixed string, as described in the Automation topic BSTR.
CURRENCY 8-byte, fixed floating-point number.
DATE 64-bit, floating point fractional number of days since December 30, 1899.
SCODE For 16-bit systems–built-in error type that corresponds to VT_ERROR.
Typedef enum myenum Signed integer, whose size is system dependent.
Interface IDispatch * Pointer to the IDispatch interface (VT_DISPATCH).
Interface IUnknown * Pointer to an interface that does not derive from IDispatch (VT_UNKNOWN). (Any OLE interface can be represented by its IUnknown interface.)
dispinterface Typename * Pointer to an interface derived from IDispatch (VT_DISPATCH).
Coclass Typename * Pointer to a coclass name (VT_UNKNOWN).
[oleautomation] interface  Typename * Pointer to an interface that derives from IUnknown.
SAFEARRAY(TypeName) TypeName is any of the above types. Array of these types.
TypeName * TypeName is any of the above types. Pointer to a type.
Decimal 96-bit unsigned binary integer scaled by a variable power of 10. A decimal data type that provides a size and a scale for a number (as in coordinates).


A parameter is compatible with Automation if its type is an Automation-compatible type, a pointer to an Automation-compatible type, or a SAFEARRAY of an Automation-compatible type.

A return type is compatible with Automation if its type is an HRESULT, SCODE or void. However, MIDL requires that interface methods return either HRESULT or SCODE. Returning void generates a compiler error.

A member is compatible with Automation if its return type and all its parameters are Automation compatible.

An interface is compatible with Automation if it is derived from IDispatch or IUnknown, it has the [oleautomation] attribute, and all of its VTBL entries are Automation compatible. For 32-bit platforms, the calling convention for all methods in the interface must be STDCALL. For 16-bit systems, all methods must have the CDECL calling convention.

Every dispinterface is implicitly Automation-compatible. Therefore you should not use the [oleautomation] attribute on dispinterface.

The [oleautomation] attribute is not available when you compile using the MIDL compiler /osf switch.




library Hello
        helpstring("Application object for the Hello application."),
    interface IHello : IDispatch
        // Interface definition statements.

    // Other library definition statements.

See also

Interface Definition (IDL) File

Generating a Type Library With MIDL

ODL File Example

ODL File Syntax