如何在C ++中扩展或修改已发布的COM对象接口 [英] How to extend or modify already published COM object interface in C++

查看:113
本文介绍了如何在C ++中扩展或修改已发布的COM对象接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已请求在已发布的COM对象中添加新方法

I have request to add new method in already published COM object

interface ItestAutomationServer : IDispatch



add one以下接口现有方法中的更多参数


add one more out parameter in existing method of following interface

interface ISinkNewAutomationTest : IUnknown 



任何人都知道如何解决这个问题?



我尝试了什么:



我继承了以下内容添加了新方法


any one knows how to solve this?

What I have tried:

I have inherited as following and added new method

interface ItestAutomationServer1 : ItestAutomationServer



我继承了以下内容并添加了带有额外参数的新方法


I have inherited as following and added new method with that extra parameter

interface ISinkNewAutomationTest1 : ISinkNewAutomationTest 

推荐答案

通常是通过新版本的界面。比实现要求所需的接口及其版本。比使用 QueryInterface 获取支持的接口的方法。请参阅示例如何支持不同的接口。



继承是一个好主意,因为它可以确保兼容性。
Normally it is done via a new version of the interface. Than the implemenation is asking for the needed interface and its version. Than use the QueryInterfacemethod to get the supported interface. See the example how to support different intefaces.

Inheritance is a good idea, because it ensures compatibility.


COM 接口 immutable 您不应尝试更改它们。您必须创建新接口。来自文档 [ ^ ]:

COM interfaces are immutable you shall not try to change them. You have to create new interfaces. From the documentation[^]:
COM接口是不可变的。您无法定义旧版本的旧版本并为其指定相同的标识符。添加或删除接口的方法或更改语义会创建一个新接口,而不是旧接口的新版本。
COM interfaces are immutable. You cannot define a new version of an old interface and give it the same identifier. Adding or removing methods of an interface or changing semantics creates a new interface, not a new version of an old interface.


这篇关于如何在C ++中扩展或修改已发布的COM对象接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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