Windows Programming/COM and ActiveX
From Wikibooks, the open-content textbooks collection
People familiar with Windows have doubtless heard a number of different terms used, such as COM, DCOM, COM+, ActiveX, OLE, etc. What precisely are all these things, and how are they related?
Contents |
[edit] Introduction to COM
COM is the general name for a method of language-neutral object oriented programming. COM essentially lays a framework for classes to be created in any language, and to be instantiated into any other languages. A class may be written in C++, and called from VisualBasic, et caetera. Essentially, COM defines an interface that all languages must follow, if they want to participate in COM programs. The acronym stands for "Component Object Model", and works like a general framework for most of Windows to operate.
ActiveX is the name for Microsoft's specific brand of COM. For instance there is a general thing in this world called "car", and there are various different brands of car (Audi, BMW, Ford...). A Ford is a car, just like an Audi is a car. Likewise, there may be many different brands of COM. ActiveX is the COM that Microsoft made.
OLE is a term that has had many meanings and uses. A common acronym for OLE is "Object Linking and Embedding", which was actually a variant of COM. However, the term OLE has been used to describe many different things over the years, and it can be very confusing to people still.
[edit] COM Libraries
COM classes, written in a compileable language (such as C++ or VisualBasic) may be compiled into DLL libraries. DLL libraries that contain COM classes are not compatible with DLL libraries written in C that contain regular C functions. However, DLL files may be compiled such that they contain both standard C functions, and COM classes.
Files that contain COM classes are refered to as "COM modules", or "COM Components". Just like with other dynamic linking applications, Windows will manage the COM interface between components automatically, so long as all the modules properly use the COM specifications.
[edit] UUID
The COM system relies on numerical identifiers know as Universally Unique Identifiers (UUID). A UUID is a 128 bit number that is essentially guaranteed to be unique COM identifier throughout the entire world. The UUID number is a hash value based on the MAC address of your primary network card (if your computer has one) and the real-time clock value of your processor. This means that the only way to generate 2 UUIDs that are identical would be to generate both at exactly the same time on exactly the same computer. Thankfully, this is impossible to do.
COM components are given a UUID number, so that they can be differentiated from all other COM components, and any given COM module can be identified by a single numeric identifier.