传统DLL和COM DLL之间的区别 [英] The difference between traditional DLL and COM DLL

查看:84
本文介绍了传统DLL和COM DLL之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在学习COM。我发现COM DLL是建立在传统DLL基础结构上的。在构建COM DLL时,我们仍然依靠传统的DLL导出方法将我们引向内部COM协同类。

I am currently studying COM. I found that COM DLL is kind of built upon the traditional DLL infrastructure. When we build COM DLLs, we still rely on the traditional DLL export methods to lead us to the internal COM co-classes.

如果COM用于二进制级别的组件重用,我认为传统的DLL可以实现相同的目的。它们都公开函数,它们都是二进制的,因此转向COM方法的意义何在?

If COM is for component reusing at the binary level, I think the traditional DLL can achieve the same thing. They both expose functions, they are both binary, so what's the point of turning to COM approach?

当前,我感觉传统的DLL在 flat 方式,而COM DLL以 OOP 层次结构方式公开方法。 OOP方式似乎是一种更好的方法。

Currently, I have the feeling that the traditional DLL expose methods in a "flat" manner, while the COM DLL expose methods in an "OOP" hierarchy manner. And the OOP manner seems to be a better approach. Could this be the reason why COM prevails?

非常感谢。

推荐答案

不,有很大的不同。 COM具有定义良好的协议,用于创建对象,公开方法,管理内存,发布类型信息,管理线程。不管用哪种语言编写,几乎没有剩下不支持使用COM服务器的语言。

No, there's a Big difference. COM has a well defined protocols for creating objects, exposing methods, managing memory, publishing type information, managing threading. There is practically no language left that doesn't support using a COM server, no matter what language it was written in.

通过公开自己的功能,您将不会得到它。直。只有使用C / C ++编写的程序(这样它才能读取您的头文件),使用与C ++编译器完全相同的版本进行编译且不存在各种互操作问题,该程序才可能可用。简单地暴露像std :: string这样的C ++类对象并不安全。既不保证内存布局兼容,也不存在任何类型的内存所有权协议。

You will not get that from exposing your own functions directly. That will likely be only usable from a program written in C/C++ (so it can read your header files), compiled with the exact same version of the C++ compiler and no lack of all kinds of interop problems. Something as simple as exposing a C++ class object like std::string is not safe. Neither the memory layout is guaranteed to be compatible, nor is there any kind of memory ownership protocol.

OOPy可能更多,COM不支持继承,因为OOP很难在二进制级别兼容。这个问题需要运行时支持,所有代码都可以买到,例如.NET和Java这样的VM。

It could well be more OOPy, COM doesn't support inheritance because OOP is so hard to get compatible at the binary level. That problem requires runtime support that all code buys into, VMs like .NET and Java.

这篇关于传统DLL和COM DLL之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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