Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is COM?

Tags:

guid

com

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

  • What COM actually is?
  • How do GUIDs work, and how are they used by COM?
  • How does COM resolve the issues of different DLL versions.

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

like image 748
Anirudh Goel Avatar asked Apr 14 '09 16:04

Anirudh Goel


People also ask

Is COM still used?

COM is still in wide use today, although it's considered an older cousin to the . NET Framework. Many technologies you rely on, and use with PowerShell, are still based on COM.

What is a COM library?

dll and Rpcss.exe) in Microsoft Windows, the COM library includes the following: A small number of fundamental functions that facilitate the creation of COM applications, both client and server. For clients, COM supplies basic functions for creating objects.

What is a COM class?

A COM class is an implementation of a group of interfaces in code executed whenever you interact with a given object.

What are COM objects Windows?

A COM object is one in which access to an object's data is achieved exclusively through one or more sets of related functions. These function sets are called interfaces, and the functions of an interface are called methods.


2 Answers

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.

How it works:

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.

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.

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.

like image 122
Charles Bretana Avatar answered Nov 12 '22 21:11

Charles Bretana


Your question is a little large for a full explanation here. A quick high-level introduction to COM can be found in the book Understanding ActiveX and OLE. A more detailed but still introductory introduction is Inside COM. The best book on the subject is Don Box's Essential COM.

A couple of quick answers:

  • COM is a binary interface standard for objects. It allows various programs to write to interfaces without all having to have been written in the same langauge with the same compiler. There are also related services available.
  • GUIDs are globally unique numbers that COM uses to identify interfaces.
  • COM doesn't resolve different DLL version problems. It only allows a single DLL to be registered for each GUID.
like image 32
Steve Rowe Avatar answered Nov 12 '22 19:11

Steve Rowe