COM 与非 COM DLL [英] COM vs non-COM DLL

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

问题描述

我的大部分经验是使用 Java 和 VB.NET 等高级语言.我确实有一些 C++ 经验(在大学).

The majority of my experience is with high level languages like Java and VB.NET. I do have some experience with C++ (at university).

我了解 COM DLL 和 .NET 编译器生成的 DLL 之间的区别.我不完全理解 C 和 C++ 编译器生成的 COM DLL 和 Windows DLL 之间的区别.

I understand the difference between a COM DLL and a DLL produced by a .NET compiler. I don't fully understand the difference between a COM DLL and a Windows DLL generated by the C and C++ compiler.

我想在 .NET 程序中使用 C++ DLL.我设法让这个工作.我的问题是:C++ 生成的 DLL 和 VB6(基于 COM)生成的 DLL 有什么区别.

I want to use C++ DLL in a .NET program. I have managed to get this working. My question is specifically: What is the difference between a DLL produced by C++ and a DLL produced by VB6 (COM based).

我花了一个小时在谷歌上搜索并查看 MSDN.我虽然不用问问题就能找到答案,但我没有.

I have spent an hour Googling this and looking on MSDN. I though I would find my answer without having to ask a question, but I have not.

推荐答案

两者之间有一个巨大的差异.该列表太长,无法在 SO 帖子中准确复制,我将尝试突出显示:

There's a giant difference between the two. The list is too long to reproduce accurately in an SO post, I'll try to hit the highlights:

  • C++ DLL 必须导出它希望提供给客户端代码的每个函数或类.一个 COM DLL 仅导出 4 个具有众所周知的名称和行为的函数
  • 使用 C++ DLL 的应用程序必须在链接时描述该 DLL 的接口,COM 服务器在运行时绑定
  • 使用 C++ DLL 的应用程序必须允许 Windows 在启动时找到 DLL,通常通过将 DLL 放在与 EXE 相同的目录或路径上.在没有客户端应用程序指定其位置的情况下找到 COM DLL.注册表在运行时用于定位 DLL
  • COM 服务器不一定是 DLL.它可以是任何东西,包括同一台机器上的单独进程或位于世界各地另一台机器上的可执行文件.客户端代码不知道它所在的位置

特定于 COM 的自动化子集:

Specific to the Automation subset of COM:

  • 任何支持 COM 的语言都可以使用 COM 服务器.在 Windows 中,这几乎是其中的任何一个.

最后一个要点可能会让您误以为您了解 COM dll 和 .NET dll 之间的区别.它们没有任何共同点,但 .NET 非常好,并且可以与 COM 服务器互操作.Tlbimp.exe 实用程序非常擅长掩盖差异.

The last bullet is possibly what trips you up about thinking that you understand the difference between a COM dll and a .NET dll. They have nothing at all in common, but .NET is pretty good and inter-operating with COM servers. The Tlbimp.exe utility is quite adept at papering over the differences.

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

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