如何为第三方定义的COM接口注册代理/存根? [英] How do I register a proxy/stub for a COM interface defined by a third party?

查看:204
本文介绍了如何为第三方定义的COM接口注册代理/存根?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

还有另一家公司运送使用IAnotherCompanyInterface的产品.我们要运送实现IAnotherCompanyInterface的COM对象.该接口与自动化不兼容,因此启用编组的下一个最简单的选择是使用代理/存根.另一家公司不运送代理/存根,也不愿意.

There's Another Company that ships the product that consumes IAnotherCompanyInterface. We want to ship a COM object that implements IAnotherCompanyInterface. That interface is not Automation-compatible, so the next easiest option to enable marshalling is using a proxy/stub. Another Company doesn't ship the proxy/stub and doesn't want to.

编译和注册代理/存根本身不是问题,但请考虑以下情况.我们公司在运送实现IAnotherCompanyInterface和ThirdPartyCompany的COM对象.因此,这两个组件最终可能都部署在同一台计算机上.

Compiling and registering the proxy/stub is not a problem by itself but consider the following situation. There's our company shipping a COM object implementing IAnotherCompanyInterface and the ThirdPartyCompany that does the same. So both components might end up being deployed on the same machine.

接口的代理/存根注册在系统范围内.他们的代理/存根实现应如何共存?

Proxy/stub registration is system-wide for an interface. How should their proxy/stub implementations co-reside?

推荐答案

自从我处理这些东西已有一段时间了,所以这是大声思考",但希望会对您有所帮助...

It's a while since I worked with this stuff, so this is "thinking aloud" but hopefully it'll be some help...

我假设您可以看到描述您要实现的接口的类型库.如果是这样,请将其加载到oleview.exe中.将提供给您的IDL复制到您自己的新.idl文件中,并在该文件中建立自己的实现.

I presume that you can see a type library that describes the interface you want to implement. If so, load it into oleview.exe. Copy the IDL it gives you into a new .idl file of your own, and base your own implementation on that file.

我知道您的问题实际上是关于代理/存根DLL的.没关系.您的计算机将与实际的COM服务器一起生成,并且将在您的计算机和用户的计算机上运行.如果您的代码安装在还安装了另一家公司"位的计算机上,那没关系...

I know your question is actually about the proxy/stub DLL. That's fine. Yours will be generated along with your actual COM server, and it will work on your machines and those of your users. If your code is installed on a machine that also has "Another Company's" bits installed, it shouldn't matter...

代理/存根只是一些代码,告诉COM如何在COM客户端和COM服务器之间传递参数和返回值.如果您的数据库是根据从其typelib生成的IDL构建的,则它们在功能上是等效的.可以通过其代理/存根成功调用您的COM服务器,反之亦然.

The proxy/stub is just a bit of code that tells COM how to transfer params and return values between COM client and COM server. If yours is built from IDL that was generated from their typelib, they will be functionally equivalent. Your COM server can be successfully called via their proxy/stub and vice versa.

但是,如果它们更改了代理/存根,则它们在功能上可能不再等效.但是在那种情况下,他们可能还会更改界面,并且您的COM服务器将不再可用于其客户端.

However, if they change their proxy/stub, they might no longer be functionally equivalent. But in that case, they probably also changed the interface and your COM server would no longer be usable by their client.

这篇关于如何为第三方定义的COM接口注册代理/存根?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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