c++ - 有没有办法手动组织 COM 编码(marshal)处理?

标签 c++ com automation marshalling

我有两个 .exe 应用程序。它们中的每一个都包含与自动化兼容的接口(interface),并在项目 IDL 中进行了描述。所以,我对这两个应用程序都有 tlb。需要从在另一个/不同应用程序中运行的代码组织实现其中一个接口(interface)的类的调用方法。它在 COM 服务器和 COM 客户端中的工作方式抛出了进程外边界。但 intrefaces 是隐私的,未在注册表中注册,因此标准 CoMarshalInterface/CoUnmarshalInterface 不起作用。 我该怎么做,手动组织编码(所有必需的数据都存在:tlb,自动化兼容接口(interface))?

附注看起来像this但没有注册表注册。

最佳答案

当类型库可用并注册后,您可能期望 COM 使用类型库信息自动创建代理/ stub 对。但这不是唯一的方法,COM 将首先通过 IMarshal 接口(interface)查询对象是否能够将自身编码到流中,IMarshal::MarshalInterface方法。

MSDN 上的编码详细信息 writes :

Custom marshaling is inherently unique to the object that implements it. It uses proxies implemented by the object and provided to the system on request at run time. Objects that implement custom marshaling must implement the IMarshal interface, whereas objects that support standard marshaling do not.

通过这种方式实现自定义编码(marshal)处理,您可以让 COM 对象将其基本信息保存到流中,并且它提供解封器的 CLSID 来在另一端重新创建接口(interface)。数据将通过进程边界传递,您的对象将被实例化并提供此流数据,以便您重新创建相关接口(interface)。

因此,实现 IMarshal 和 friend ,您将能够集成到 COM 处理中,而无需注册甚至不可用类型库。

关于c++ - 有没有办法手动组织 COM 编码(marshal)处理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12843552/

相关文章:

C++ 获取毫秒时间

c++ - 如何解决 numeric_limits<T>::min() 的不一致定义?

c# - stdole.dll 有什么作用?

python - 使用pythonnet实例化后如何让msaccess及其属性可用?

c# - 卸载 appdomain 不清除 C++ COM 对象静态成员

automation - 使用 Testcafe 定义选择器

c# - 以编程方式与 IE 浏览器交互以填写表单和导航等

c++ - 从哪里获得用于面部表情识别的 SVM 训练数据?

c++ - 为什么我收到语法错误 : missing ';' before '*'

mysql - 在 MySQL 8.0 中自动插入额外的列