noncreatable attribute

The [noncreatable] attribute defines an object that cannot be instantiated by itself.

[
  coclass-attribute-list, 
    noncreatable
]
coclass coclass-name
{
  coclass-interface-list
}

Parameters

coclass-attribute-list

Other attributes that apply to the class.

coclass-name

The name of the class.

coclass-interface-list

A list of interfaces for the class.

Remarks

Use the [noncreatable] attribute on a coclass statement to indicate to users that they cannot create a new object of this class at the top level—that is, by calling CreateInstance or CoCreateInstance. Instantiation of an object of this class requires a method call to another object. For example, in Microsoft Excel, the "Cell" object is noncreatable and must be obtained from a Microsoft Excel Worksheet object.

Methods that return instances of noncreatable classes should return the exact type of the object, rather than VARIANT or IDispatch* types.

Typeflag Representation:

The absence of TYPEFLAG_FCANCREATE.

Examples

[
    uuid(12345678-1234-1234-1234-123456789ABC),
    helpstring("This is MyCOClass"),
    noncreatable
]
coclass MyCoClass
{
    [default] interface IMyClass;
    [default, source] dispinterface IMyClassEvents;
}

See also

coclass

ODL File Syntax

ODL File Example

Generating a Type Library With MIDL