组件类特性

coclass 语句提供组件对象支持的接口列表。

[
    coclass-attribute-list
]
coclass classname
{
    [
        interface-attributes
    ] 
    [interface | dispinterface] interfacename 
    {
  . . . 
    }
}

参数

coclass-attribute-list

[uuid] 属性在 coclass 上是必需的。 这与在系统注册数据库中注册为 CLSID 的 [uuid] 相同。 在 coclass 定义之前,接受 [helpstring][helpcontext][licensed][version][control][hidden][appobject] 属性。

classname

在类型库中已知公共对象的名称。

interface-attributes

接口或调度接口的可选属性。 [source][default][restricted] 属性在 coclass 中的接口或 dispinterface 上接受。

interfacename

使用接口关键字 (keyword) 声明的接口,或使用 dispinterface 关键字 (keyword) 声明的 dispinterface

备注

Microsoft 组件对象模型将类定义为允许在一组接口之间 使用 QueryInterface 的实现。

示例

[
    uuid(1e196b20-1f3c-1069-996b-00dd010fe676), 
    version(1.0), 
    helpstring("A class"), 
    helpcontext(2481), appobject
] 
coclass myapp 
{ 
    [source] interface IMydocfuncs : IUnknown; 
    dispinterface DMydocfuncs; 
}; 
 
[
    uuid(12345678-1234-1234-1234-123456789ABC)
] 
coclass mycoclass 
{ 
    [restricted] interface iface1; 
    interface iface2; 
}

另请参阅

appobject

控制

默认

dispinterface

使用 MIDL 生成类型库

ODL 文件示例

helpstring

helpcontext

隐藏

接口

许可

ODL 文件语法

限制

TYPEFLAGS

uuid

版本