简体   繁体   English

如何在原始C语言中编写COM服务器?

[英]How to write a COM server in raw C?

I am studying COM. 我正在学习COM。 I think the best way to get a thorough understanding of COM is write one without any COM framework such as ATL. 我认为,全面了解COM的最好方法是编写一个没有任何COM框架(例如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? 我已经用原始C ++编写了一个COM服务器,现在我想用普通的原始C编写一个COM服务器。我该怎么做? Is there any tutorial? 有教程吗?

Many thanks. 非常感谢。

Writing COM servers in C is not impossible. 用C编写COM服务器并非不可能。 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. 仅仅是COM代码已经很强大,在C语言中它将变得更加强大,因为您不会从兼容的C ++编译器生成的内置v表支持中获得帮助。 Or a class library like ATL. 或像ATL这样的类库。 You have to create your own. 您必须创建自己的。

A good source for COM example code written in C is the WINE project. WINE项目是C语言编写的COM示例代码的一个很好的来源。 For example, the implementation of the IGlobalInterfaceTable interface . 例如, 实现IGlobalInterfaceTable接口 Note the GITClassFactoryVtbl in that code, that's the interface dispatch table for the class factory, and StdGlobalInterfaceTableImpl_Vtbl, the dispatch table for IGlobalInterfaceTable. 请注意该代码中的GITClassFactoryVtbl,即类工厂的接口调度表,以及StdGlobalInterfaceTableImpl_Vtbl,即IGlobalInterfaceTable的调度表。

Not so sure that this will give you a deeper insight in COM programming. 不太确定这是否会使您对COM编程有更深入的了解。 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. Don Box的《 Essential COM》一书是最好的书之一,从根本上解释了有关COM的所有内容。 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. 但是,COM是使用十年的技术,需要用C进行大量工作,而Don Box(以前被认为是专家之一)甚至都不再使用它。 Take what you will from that. 从中得到你想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM