问题
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.
Where to start? Any ideas? Any example (like Hello World DCOM)?
回答1:
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".
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.
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.
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++.
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.
Make sure whatever book you get is written for the version of Visual Studio and/or ATL you are planing on using.
Some background on COM books:
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.
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 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.
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.
In summary:
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.
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.
Good luck.
回答2:
COM, COM+ and DCOM are three completely different things. At this point, there is very little reason to learn COM and almost no reason to learn DCOM. The only reason I can think of is if you have to maintain or integrate legacy components. COM+ is still used because it allows for out of process hosting of components and nice things like distributed transaction management.
The best way to start writing up some COM is using ATL. In .NET COM+ is called Enterprise Services.
The best book I know on COM is Don Box's Essential COM and Tim Ewald's COM+ book is excellent too.
回答3:
I compiled a list of books, which should be read in this order:
- 'Inside COM' from Dale Rogerson, This should be your first book. It explains the basics of reference counting, interfaces, IUnknown, components, idl, IDispatch, automation types and apartments. From this book you will notice that it takes quite some code to make components and that you can easily skip a 'Release', which leads to resource leaking. Also this books lacks some details.
- 'ATL Internals' from Tavares. ATL helps you with both client use as making COM components. With smart pointers (e.g. CComPtr) it's hard to get the reference counting wrong these days. ATL also facilitates in making components in c++. Unfortunately ATL hides many functionality in macro's and has a counter intuitive way to implement IUnknown. An alternative might be 'Inside ATL'.
- 'Essential COM' from Don Box. This book is mentioned frequently but it is not a good beginners book. It misses the overall picture, but is great in its details (e.g. the difference between 'size_is' and 'length_is' in idl).
- 'Understanding ActiveX and OLE: A Guide for Developers and Managers'. This books touches some of the more esoteric interfaces like IPersist, IStorage; IMoniker etc., but does not go into great detail.
Be aware that COM is somewhat of an old technology, though still viable especially for native developers.
回答4:
COM is still useful if you want to work with, or extend, various Windows APIs, such as shell extensions, scripting host, and so on.
Essential COM (Box) and ATL Internals (Rector and Sells) are excellent sources. Effective COM (Box, et al) is also ok.
If you really want the full picture on COM, try and get a copy of the immense Inside OLE (Brockschmidt).
Distributed COM (Eddon, Eddon) is decent on DCOM, as is Inside COM+ Base Services (Eddon, Eddon) on COM+.
even some supposedly "pure" C++ books have bits on COM in them. Matthew Wilson's Imperfet C++ has some useful parts for seeing how it works on the inside, and his Extended STL book has a couple of chapters on how to adapt COM to STL collections.
If you want to know more about how to write COM servers, you'll probably need to bone up on ATL. The aforementioned ATL Internals is a must. Despite its humble sounding title, Beginning ATL COM has some useful stuff in it too.
Also helpful in the learning process might be to contrast COM with .NET. The .NET and COM Interoperability Handbook is a big swallow, but has some useful stuff in it. Also, I would check out Shared Source CLI Essentials, just to help contrast the two technoloqies.
HTH
回答5:
Start with "Inside COM", then move on to "Inside DCOM" and then read the "Essential COM". You will get a grip on COM. Both the books Inside COM and Inside DCOM are Microsoft Publications. Excellent books for the one who wants to know COM/DCOM thoroughly.
回答6:
Essential COM is especially for implementing or using COM components from C++, without using an IDE, framework, or library to help.
COM is trivial to use from VB or from Delphi, for example, which hide the COM-specific glue from the application programmer. In C++ you'd often use some class library that tries to abstract the details ... Essential COM will tell you what those details are (and kind of implements its own library/framework in doing so).
回答7:
Actually, if you want to learn more about COM, Microsoft publishes a book about COM and how it works... http://www.amazon.com/Inside-Microsoft-Programming-Dale-Rogerson/dp/1572313498/ref=sr_1_2?ie=UTF8&s=books&qid=1243029018&sr=8-2
来源:https://stackoverflow.com/questions/900123/com-com-dcom-where-to-start