tags:

views:

66

answers:

2

I am studying COM. I think the best way to get a thorough understanding of COM is write one without any COM framework such as ATL. I have written a COM server in raw C++, and now I want to write one in plain raw C. How could I do this? Is there any tutorial?

Many thanks.

+2  A: 

Don Box's book Essential COM is one of the best that explains everything about COM from the ground up. Recommended.

COM, however, is decade old technology that's a heck of a lot of work to do in C, and Don Box (previously considered one of the experts) doesn't even touch it anymore. Take what you will from that.

Greg Hewgill
-1 For first para (I think Box's books are (euphemistically) not very good. +1 For the second. For a real COM from the ground up, read Inside COM by Dale Rogerson.
anon
+1 for pointing out that COM is evil.
Swingline Rage
+2  A: 

Writing COM servers in C is not impossible. It is just that COM code is already beefy, it will be quite a bit beefier in C since you don't get help from the built-in v-table support that a compliant C++ compiler generates. Or a class library like ATL. You have to create your own.

A good source for COM example code written in C is the WINE project. For example, the implementation of the IGlobalInterfaceTable interface. Note the GITClassFactoryVtbl in that code, that's the interface dispatch table for the class factory, and StdGlobalInterfaceTableImpl_Vtbl, the dispatch table for IGlobalInterfaceTable.

Not so sure that this will give you a deeper insight in COM programming. It is unlikely you'll ever write a real server like this. Have you written an out-of-process server yet?

Hans Passant
Thanks for your reply. It does give me great insight. I have written an in-process com server in C++.
smwikipedia
+1 for this answer provide some information on "COM under C",not just criticize the evil of COM
lz_prgmr