gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-31 01:52:19 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com