tags:

views:

504

answers:

4

I 've managed to somehow avoid learning COM so far, although I 've been programming C++ under Windows for several years now.

At this point there are lots of bits and pieces related to COM and how it works in a big ball of mud in my head. So I decided that it's time to bite and do some learning... which will be helped greatly by a good book. What is the best one to get started on comprehending COM?

To clarify and allow good people to answer the above question better:

  • My intention is to learn stuff that will increase my general awareness of "how it all binds together" and help me improve as a developer, not learn non-transferable skills.
  • I 'm very experienced, able to make good use of deep books; don't hesitate to suggest such if they 're worth it.
  • I 'm not looking for "practical COM programming" in the first instance; rather, a book that firstly explains how COM is built and why, how it all works, etc.
  • C++ focus would be a major plus.
  • Being in print would be a major plus too!

Thanks in advance!

+6  A: 

"Inside COM" by Dale Rogerson (MS Press) was an excellent resource in its day. I believe it is out of print, but Amazon seems to have a few secondhand ones for sale.

Also, if you haven't already, take a look at the MSDN COM Guide.

Mitch Wheat
I'll second that. I read several books on COM years ago and Inside COM was easily the best in my opinion.
John D. Cook
Inside COM is simply the best book, you'll get understanding and avoid misconceptions i've seen from "certified" COM+ programmers.
eugensk00
+7  A: 

I bought Essential COM (1998) by Don Box in 2001. It was good.

yogman
read couple chapters .good read for c++ developer
yesraaj
I tend to prefer this one over Inside COM.
Preets
Don't feel obligated to read all of it. Despite the name, much of the book is not essential, at least not at first.
John D. Cook
Agree. I got at least a basic understanding of COM from the first few chapters. Not sure if much more is necessary any more.
Jim Anderson
Essential COM goes into a lot of arcane detail about marshalling that is really useful if you are dealing with some of the subtleties of COM. There are some save-for-later chapters (not for beginners) but I wouldn't call it "unnecessary"
Jason S
I agree with you Jason. I never understood the threading models then, and don't want to. But, thanks to it, I could adopt the COM approach in a bare-bone embedded system, Qualcomm's DMSS/BREW. All you have to do was implement GetClassObject, and IUnknown for each C++ class.
yogman
+3  A: 

David Chappell's Understanding ActiveX and OLE is an old work but it's very good (gets 5 star average on Amazon.com) and quite easy to read. You can get secondhand ones through Amazon Marketplace pretty cheaply. After that, Box's Essential COM (already mentioned by yogman +1) is quite a good book to dig deeper. Finally, Troelsen's Developers Workshop to COM and ATL 3.0 is another good book, with more of a reference to ATL.

ConcernedOfTunbridgeWells
+5  A: 

Here's my list (also see the newsgroup microsoft.public.vc.atl which is invaluable for asking questions):

  • Essential COM (Don Box), as mentioned.
  • Effective COM (Box, Brown, Ewald, Sells)
  • ATL Internals (Rector, Sells) (note, there's now a 2nd edition covering ATL 8.0... I assume it's of similar quality but have not seen it myself)
  • Inside OLE (Brockschmidt) out of print (NOTE: you want the second edition, NOT Inside OLE 2, which is an earlier edition. Confusing!). This covers some things that predate COM but are covered in more detail than I've found in the COM books, e.g. monikers and IDataObject.
  • The Essence of COM with ActiveX (Platt) out of print. This I found helpful in part because of his writing style. It's kind of smart-ass but he says what he thinks.
  • Beginning ATL 3 COM Programming (Grimes et al) - not as good as the others but Grimes gets cited every now and then.

Of these, the first three I listed are the ones I would recommend most highly. I strongly recommend using ATL and its "smart" classes CComPtr<>, CComBSTR, CComVariant. It's a little weird at first (recursive templates e.g. class Foo : public Bar<Foo,Baz<Foo> > { ... } ) but will save you tons of hassle. It's actually possible to develop COM objects in plain C (bleah!) by explicit vtables, or even assembly, but that's for masochists.

Jason S