什么是 COM? [英] What is COM?

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

问题描述

我努力搜索,但无法掌握整个想法.谁能告诉我:

I searched hard, but was unable to grasp the whole idea. Can anyone tell me:

  • COM 究竟是什么?
  • GUID 如何工作,COM 如何使用它们?
  • COM如何解决不同DLL版本的问题.

或者至少,给我指出一篇解释这些概念的好文章?谢谢!

Or at least, point me to a good article somewhere that explains these concepts? Thanks!

推荐答案

COM 是组件对象模型".它是最早设计用于允许二进制重用"组件的技术之一……最初,它是对 Microsoft Office 大约 1988-1992 年的时间框架(称为动态数据交换 (DDE))的重写,旨在让各种 Office 应用程序相互通信的技术.重写它的第一次尝试称为 OLE-Automation(对象链接和嵌入).但是当他们完成后,他们将其重命名为 COM.

COM is "Component Object Model". It is one of the first technologies designed to allow "binary reuse" of components... Originally, it was the rewrite of what was, in Microsoft Office circa 1988-1992 time frame, referred to as Dynamic Data Exchange (DDE), a technology designed to allow the various Office applications to talk to one another. The first attempt to rewrite it was called OLE-Automation (Object Linking and Embedding). But when they got done they renamed it to COM.

它是如何工作的:

本质上,在 COM 之前,当客户端组件想要使用一个组件(编写为 C++ 库)时,它必须与库一起编译,因此它可以准确地知道编译后的二进制文件中有多少字节才能找到每个方法或函数调用.

Essentially, before COM, when a client component wanted to use a component (written as a C++ library), it had to be compiled WITH the library, so it could know exactly how many bytes into the compiled binary file to find each method or function call.

对于 COM,有一个关于如何构建这些方法的定义机制,然后编译器生成一个单独的文件(称为类型库或接口定义语言 (IDL) 文件,其中包含所有这些函数偏移数据.

With COM, there is a defined mechanism as to how these methods will be structured, and then the compiler produces a separate file (called a type library or an Interface Definition Language (IDL) file, that contains all this function offset data.

然后,作为组件的用户,您必须注册"它,它将所有这些信息(从 GUID 键入)写入操作系统注册表,任何客户端应用程序都可以访问它,并通过从注册表,它可以知道在二进制文件的哪里找到每个方法或类的入口点.

Then, as a user of the component, you have to "register" it, which writes all this information (Keyed off of GUIDs) into the OS Registry, where any client app can access it, and by reading the data from the registry, it can know where in the binary file to find each method or class entry point.

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

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