在 IDL 中将 IUnknown 派生接口标记为对偶有什么意义? [英] Any sense in marking an IUnknown-derived interface as dual in IDL?

查看:17
本文介绍了在 IDL 中将 IUnknown 派生接口标记为对偶有什么意义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看我们的代码,我在一个 .idl 文件中发现了一个奇怪的定义:

Reviewing our code I've found a curious definition in one of .idl files:

[
    object,
    uuid(uuidhere),
    dual,
    nonextensible,
    oleautomation,
    hidden
]
interface IOurInterface : IUnknown {
    //methods here
};

直接从 IUnknown 派生的接口怎么可能是双接口?如果我删除 dual 属性,会有什么问题吗?

How can an interface derived directly from IUnknown possibly be a dual interface? Will anything break if I remove the dual attribute?

推荐答案

this answer 另一个关于编组 用户 voyce 指向 这篇文章,基本上说明了以下内容:

In this answer to another question concerning marshaling user voyce points to this article that basically states the following:

当任何接口(IDispatch 派生或不派生)被标记为 dualoleautomation(或两者)时,当 RegisterTypeLib() 被调用(通常由 DllRegisterServer 完成).对于每个这样的接口,都会创建一个 HKCRInterface{InterfaceId} 键,在该键下 {00020424-0000-0000-C0000-000000000046} 类被引用为代理/存根.此类 id 对应于 typelib marshaller,也称为 oleautomation marshaller.

When any interface (IDispatch-derived or not) is marked either dual or oleautomation (or both) it is treated specially when RegisterTypeLib() is invoked (which is typically done by DllRegisterServer). For each such interface an HKCRInterface{InterfaceId} key is created under which {00020424-0000-0000-C0000-000000000046} class is referenced as proxy/stub. This class id corresponds to typelib marshaller also known as oleautomation marshaller.

这篇关于在 IDL 中将 IUnknown 派生接口标记为对偶有什么意义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆