有关COM / ActiveX对象问题 [英] Questions about COM/ActiveX objects

查看:183
本文介绍了有关COM / ActiveX对象问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个传统的.dll 工作良好的知识。此外动态加载的区别静态加载

I have good knowledge on the working of a "traditional" .dll. Also the differences between dynamic loading and static loading, etc.

不过,我对COM对象的工作如下疑惑,

But I have the following doubts about the working of COM objects,


  • 这是必须以 REGSVR32 来注册COM对象?

  • 我能有一个注册的 COM对象的两个版本趴在相同/不同的目录?

  • 除了被打包的.dll文件里面有什么共同的传统的.dll COM对象

  • Is it mandatory to register COM objects with regsvr32?
  • can I have two versions of a registered COM object lying in the same/different directory?
  • besides being packaged inside a .dll file is there anything in common between a "traditional" .dll and a COM object?

推荐答案

1)否 - 这是没有必要注册COM的对象的。需要注册创建的新的的COM对象。有迹象表明,需要一个COM对象很多接口(COM或本机功能)。他们的API告诉你,你的COM对象应该支持的接口。既然你在现有的COM对象传递,他们不需要注册信息来创建你的COM对象。此方案的一个变化是运行对象表,在其中您可以创建注册COM对象。也是由您创建这些对象,你不需要注册信息。

1) No - it is NOT necessary to register COM objects. Registration is needed to create new COM objects. There are many interfaces (COM or native functions) that want a COM object. Their API tells you which interface your COM object should support. Since you pass in an existing COM object, they don't need registration information to create your COM object. A variation of this scenario is the RUnning Object Table, in which you can register created COM objects. Those objects are also created by you, and you don't need the registration info.

例如接口。IQueryCancelAutoplay

Example interface: IQueryCancelAutoplay.

2)COM的对象的存在于内存中。你可能想一个COM的的,在一个DLL与COM工厂一起实施。 COM类是由他们的GUID注册。你可以有多发性类=每次的GUID DLL,但每班只有一个DLL。请记住,来电询问COM为你的类的实例。这将DLL加载COM是否会有两个DLL实现同一类?
当然,可以有两个DLL各执行一班,其中两个类共享一些接口。它们将总是共享的IUnknown,例如经常的IDispatch,但很少IAcmeCorpFooBarv2

2) A COM object exists in memory. You're probably thinking about a COM class, implemented in a DLL together with its COM factory. COM classes are registered by their GUID. You can have multipe classes=GUIDs per DLL, but only one DLL per class. Remember, the caller asks COM for an instance of your class. Which DLL would COM load if there would be two DLLs implementing the same class?! Of course, there can be two DLLs each implementing one class, where the two classes share some interfaces. They will always share IUnknown, for instance, often IDispatch, but rarely IAcmeCorpFooBarv2

3)COM DLL的的一个正常的DLL其中(a)暴露了一些特定的COM-功能和(b)被注册以便COM framewrok可以调用LoadLibrary就可以了。该DLL还可能会使其他非COM功能。这样一来,就可以调用LoadLibrary一个COM DLL自己。这可以偶尔会减少参与创建第一个COM对象的等待时间是有用的。

3) A COM DLL is a normal DLL which (a) exposes some COM-specific functions and (b) is registered so the COM framewrok can call LoadLibrary on it. The DLL may also expose other non-COM functions. As a result, you can call LoadLibrary on a COM DLL yourself. This can occasionally be useful to reduce the latency involved in creating your first COM object.

这篇关于有关COM / ActiveX对象问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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