升级COM回调接口
Upgrading COM call-back interface
COM连接点回调接口有问题
在我们的样本中。如果我们有很少的回调接口ISomeEvents
interface ISomeEvents : IUnknown
{
HRESULT Event1([in]int nData);
HRESULT Event2([in]int nData);
HRESULT Event3([in]int nData);
}
And in the CoClass we have the following statement
coclass MyComp
{
[default] interface IMyInterface;
interface IMyInterFace2;
[default, source] interface ISomeEvents;
};
现在每当我们添加新的接口作为增强的一部分,这不会破坏现有的客户端,但如果增强有对回调的任何修改最终都会更新接口ISomeEvents,这会破坏现有的客户端,我们被迫这样做,因为我认为我们可以只有一个[default,source]接口。
谁能告诉我这个问题的解决方法是什么?
的问候汤姆
如果您正在开发一个COM对象,其中客户端处于活动/生产状态,那么您真的不应该更改现有的接口,任何接口。这一直是COM开发的基本规则:"接口是不可变的";当然,在早期开发过程中也会有例外。
(这里引用一个例子:"COM接口是不可变的。你不能定义一个旧接口的新版本并给它相同的标识符。"(http://msdn.microsoft.com/en-us/library/windows/desktop/ms688484 (v = vs.85) . aspx)。在web上查找"interfaces are immutable"获取更多信息)
在这种情况下,您应该根据需要创建新的接口ISomeEvents2
、ISomeEvents3
等,并让这些接口从以前的版本继承。将新接口作为新的默认源。
interface ISomeEvents1 : ISomeEvents
{
/* new enhanced events here, for use by newly compiled clients */
}
最后,如果你需要更多的修改:
interface ISomeEvents2 : ISomeEvents1
{
/* Even newer enhanced events here, for even newer clients */
}
等等
相关文章:
- 架构决策:返回std::future还是提供回调
- 正在为Xtensa simcall函数编写回调函数
- 如何在C++中使用非静态成员函数作为回调函数
- FLTK:按下哪个按钮 - 将数字传递给按钮的回调 (lambda)
- 在简单示例中,Python3 + ctypes 回调会导致内存泄漏
- 用于在回调中调用解析器的设计模式
- 如何使用C++对象的成员函数作为 C 样式回调?
- Java从C++回调到C++回调
- 如何将成员函数作为回调参数传递给需要"typedef-ed"自由函数指针的函数?
- 用接口或函数对象回调
- 回调函数中的接口类会导致崩溃
- 如何使用接口实现回调
- 自lambdas进入C++以来,“回调”接口是否已过时
- VDS(虚拟磁盘服务)COM接口通知-仅在注销期间调用回调(接收器)(Unadvise)
- 当使用来自c的回调接口时,避免在c++中使用静态成员函数
- 使用 C++11 接口包装 C 回调的最佳方法是什么?
- ATL 进程外回调接口上的'Interface not Registered'错误
- c++回调非静态接口方法
- 升级COM回调接口
- 回调(std::function/std::bind)与接口(抽象类)的优缺点