第三方组件的 COM 代理
我正在编写一个小型 DLL 组件,它需要访问两个第三方组件来组合数据,其中一个仅是 32 位,另一个仅是 64 位。两者都在 TypeLib 中注册并且与自动化兼容,因此编组不应成为问题。
如果我正确理解文档,那么除非组件也有 AppID 和 DllSurrogate 键,否则无法强制加载代理项;由于两者都是第三方组件,我有点不愿意修改它们的注册。
有没有办法在 DLL 组件的代理进程中激活没有 AppID 的组件中的对象,理想情况下没有任何额外的依赖项,或者有人可以向我解释为什么这是一个坏主意吗?
I'm writing a small DLL component that needs to access two third party components to combine data, one of which is 32 bit only and the other is 64 bit only. Both are registered with a TypeLib and are Automation compatible, so marshalling should not be an issue.
If I understood the documentation correctly, then there is no way to force loading in a surrogate unless the component also has an AppID and the DllSurrogate key; since both are third party components, I'm somewhat reluctant to modify their registration.
Is there a way to activate an object in a component without an AppID in a surrogate process from a DLL component that ideally does not have any extra dependencies, or can anyone explain to me why this would be a bad idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以在代理中加载(例如)仅 32 位的 DLL,并通过以下方式从 64 位进程访问它。如果有可用的编组器,则这将起作用,通常对于具有类型库的组件来说,这是因为它们通常使用标准编组器。如果对象需要自定义 prox/stub,则它将不起作用,因为 64 位版本不存在,否则您一开始就不会遇到此问题。
首先你需要一个AppID。如果 DLL 已有 AppID,则应使用它。您可以通过检查您感兴趣的 CoClass 的 CLSID 密钥来找到答案。
此处使用的示例是
Capicom.HashedData
和Capicom.EncryptedData
类。 Capicom 仅支持 32 位。您应该使用 32 位版本的 Regedit 来执行此操作,因为它是一个 32 位组件。如果您想从 32 位访问 64 位组件,请使用另一个。 (这是因为 32 位兼容层的注册表虚拟化 - 使用匹配位数版本的 regedit 可以通过确保编辑正确的注册表虚拟化版本来解决此问题)。
保存到
myComponent-dllhost.reg
文件,然后就可以了。您现在应该能够从 64 位脚本/COM 主机访问 Capicom.HashedData 和 Capicom.EncryptedData。
注意:
Yes, you can load a (for example) 32-bit only DLL in a surrogate, and access it from a 64-bit process, in the following manner. This will work provided there is a marshaller available, which there generally will be for a component with a typelib because they usually use the standard marshaller. It will not work if the object requries a custom prox/stub because 64 bit versions won't exist, or you wouldn't have this problem in the first place.
First you need an AppID. If the DLL already has an AppID, you should use that. You can find out by checking under the CLSID key for the CoClass you are interested in.
The example used here is the
Capicom.HashedData
andCapicom.EncryptedData
classes. Capicom is 32-bit only.You should use the 32-bit version of Regedit to do this, as it is a 32-bit component. If you have a 64-bit component you want to access from 32-bits, use the other one. (This is because of the registry virtualisation for the 32-bit compatibility layer- using the the matching bitness version of regedit takes care of this issue for you, by making sure you edit the correct virtualised version of the registry).
Save to a
myComponent-dllhost.reg
file, and away you go.You should now be able to access Capicom.HashedData and Capicom.EncryptedData from 64-bit script/COM hosts.
Notes: