Why COM
-
Hi Experts, I am new to COM programming. (Component Object Model.) After learning some theory behind COM, I am wondering Why COM when every thing is possible using DLLs which exports C++ classes. Or What is possible only in COM and not possible in C++ DLLs. Could anyone explain? Thanks in advance
cheers Varghese Paul
-
Hi Experts, I am new to COM programming. (Component Object Model.) After learning some theory behind COM, I am wondering Why COM when every thing is possible using DLLs which exports C++ classes. Or What is possible only in COM and not possible in C++ DLLs. Could anyone explain? Thanks in advance
cheers Varghese Paul
Hi there. This article might be useful I believe. What you suggest is treated in the "C++ Naive Approach: Exporting a Class" section, whereas the COM approach is similar to the described in the "C++ Mature Approach: Using an Abstract Interface" section. In short, there are many problems with simply exporting classes from a DLL. If you change a dependency, most likely you'll have to recompile them all. You have to have the same compiler and even compile with the same settings. A nightmare if you're planning on distributing your components to other people. Cheers.
Stupidity is an International Association - Enrique Jardiel Poncela
-
Hi Experts, I am new to COM programming. (Component Object Model.) After learning some theory behind COM, I am wondering Why COM when every thing is possible using DLLs which exports C++ classes. Or What is possible only in COM and not possible in C++ DLLs. Could anyone explain? Thanks in advance
cheers Varghese Paul
If you can get a copy of Don Box's "Essential COM", I would recommend it. It explains the evolution of COM clearly and thoroughly (but, it's fairly abstract reading). There are two basic concepts that are the core of COM: (1) COM objects are binary-compatible with COM objects and methods written in any other programming language (the compiler vendor implements this feature). This means that you can call CoCreateInstance for any existing, valid COM object (written in any language) and use an instance of that COM object and its methods in an your external program, just by linking to the existing DLL. (2) COM Interfaces cannot be altered once they are published. This is an attempt to eliminate what is known as "DLL Hell". This occurs when a COM component is re-written and re-compiled, changing some signatures of object method calls and causing existing compiled clients that utilize these new methods to fail when a type or method executes with an incorrect memory allocation. There is A Huge Number of Excellent COM Tutorials Right Here at CodeProject[^] An Excellent Two-Part Beginner Tutorial Series about COM is Introduction to COM, What It Is and How To Use It[^] and Part Two, Behind The Scenes of a COM Server[^], by Michael Dunn is a good place to start.