COM、COM+、DCOM,从哪里开始?

2022-01-14 00:00:00 com c c++ com+ dcom

我对 COM+、DCOM 很好奇.我知道 MSFT 不鼓励您在本地使用这些工具(意思是使用 C/C++,实际上没有很多可用的文档),但我想学习使用这些技术,比如将 Internet Explorer 嵌入到 C 程序中.

I am curious about COM+, DCOM. I know that MSFT does not encourage you to use this tools natively (meaning with C/C++, in fact there is not a lot of documentation available) but I want to learn to use these technologies, like embedding Internet Explorer into a C program.

我想也许我可以找到使用此技术或了解此技术的人.

I thought that maybe I could find people that worked with this or that knows about this technology.

从哪里开始?有任何想法吗?任何示例(如 Hello World DCOM)?

Where to start? Any ideas? Any example (like Hello World DCOM)?

推荐答案

如果你是认真学习COM的,Don Box的《Essential COM》绝对是一本绝对的必读".COM 可能会令人困惑,在我看来,Don Box 是少数真正明白"的人之一.

If you are serious about learning COM, Don Box's "Essential COM" is definitely an absolute "must read". COM can be confusing and in my humble opinion Don Box is one of the few people who actually "got it".

Essential COM"中的示例代码是 C++.你不会找到很多支持 C 语言的书.你可以用 C 语言编写 COM,但是会非常非常、非常痛苦.COM 针对 C++ 开发进行了优化.

The example code in "Essential COM" is in C++. You won't find many books that support COM in C. You can write COM in C, but it will be very, very painful. COM is optimized for C++ development.

这本书既不完美也不完整".这本书略读了一些(当然,有点深奥)领域.例如,这本书有大约 1 1/2 页的绰号"(我从未见过让我满意的绰号处理).我认为这本书是最基础的书.

This book is not perfect nor "complete". There are some (granted, a bit esoteric) areas that the book skims over. For example, the book has like 1 1/2 pages on "monikers" (I have never seen a treatment of monikers that satisfies me). I consider this book to be THE fundamental book.

其次,在现实生活中,您可能希望使用 ATL 等支持库,而不是直接编写所有 COM 胶水.即使在基本设置中,也有太多方法可以在 COM 中犯细微的错误.ATL 将为您提供良好的模式并为您实现无聊的代码.在学习中,最好使用纯 C++.

Second, in real life you are likely to want to use a supporting library such as ATL, rather than writing all the COM glue directly. There are too many ways to make subtle mistakes in COM even in the basic set up. ATL will give you good patterns and implement the boring code for you. In learning, you are better off using plain C++.

关于 ATL 的书籍很多,有几本相当不错.我知道自 VC++6 的旧时代以来,ATL 已经发生了很大的变化,但我没有第一手的知识:遗憾的是,我使用的大部分 COM 代码永远锁定在 VC6 中的 C++ 风格.

There are many books about ATL and several are quite good. I understand that ATL has changed quite a bit since the old days of VC++6, but I don't have first hand knowledge there: sadly, most of the COM code I work with is forever locked to the flavor of C++ in VC6.

确保您获得的任何书籍都是针对您计划使用的 Visual Studio 和/或 ATL 版本编写的.

Make sure whatever book you get is written for the version of Visual Studio and/or ATL you are planing on using.

COM 书籍的一些背景知识:

Some background on COM books:

请注意,有很多书误解了 COM,或者关注了错误的事情.旧书在这方面更差.前几本书中的一些将 COM 视为使 OLE 工作所需的管道细节(对象链接和嵌入",这就是允许您将电子表格范围拖放到 Word 文档中的原因).正因为如此,那里的很多材料都非常混乱.人们过了一段时间才意识到 OLE 并不那么重要,而 COM 确实如此.

Note that there are a lot of books out there that misunderstand COM, or focus on the wrong things. The older books are worse in this respect. Some of the first few books treated COM as little more than a plumbing detail needed to make OLE work ("Object Linking and Embedding", that's what allows you to drag-and-drop a spreadsheet range into a Word document). Because of that, a lot of the material out there is very confusing. It took a while before people realized that OLE wasn't that important and that COM really was.

当 Don Box 发表《Essential COM》时,COM 基础上的裂痕已经开始显现.COM 没有任何严重的缺陷,但开发社区的需求已经发展并超出了 COM 在不进行重大改造的情况下所能做的事情.

By the time Don Box published "Essential COM", the cracks on the foundation of COM had started to become evident. There isn't anything terribly flawed with COM, but the needs of the development community had evolved and outgrown what COM could do without serious revamping.

.NET 的诞生就是为了解决 COM 中的局限性,尤其是在类型信息"领域.在Effective COM"出版仅仅几年之后,社区的注意力就转移到了.NET.正因为如此,好的 COM 培训材料现在而且很可能永远是有限的.

.NET was born out of that effort to address the limitations in COM, especially in the area of "type information". Just a few years after "Effective COM" was published, the attention of the community shifted away to .NET. Because of that, good COM training material is now and will likely remain forever limited.

所以,COM 没有损坏,它在它所用的东西上工作得很好(这就是 Explorer 仍然使用它的原因).对于当今需要解决的许多问题,它不再是最佳解决方案.

So, COM is not broken, and it works great for the things it's used for (that's why Explorer still uses it). It's just not the best solution anymore for many of the problems that need solving today.

总结:

我推荐基本 COM"作为基础.然后,可以使用许多优秀的 ATL 书籍中的任何一本(那里没有强烈的偏好),然后使用其他资源,如 MSDN 或 - 当然 - Stack Overflow,来涵盖您特别感兴趣的领域.

I recommend "Essential COM" for the basics. Then, any of many good ATL books available (no strong preferences there), and then use other resources like MSDN or -- of course -- Stack Overflow, to cover areas that are of particular interest to you.

如果您不想依赖死树资源,请继续从网络学习 ATL.但是有些书值得以老式的方式阅读――《Essential COM》就是其中之一.

If you'd rather avoid relying on resources of the dead-tree variety, go ahead and learn ATL from the web. But some books are worth reading the old fashioned way -- and "Essential COM" is one of them.

祝你好运.

相关文章