开发者

How to write a COM server in raw C?

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.


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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜