Exceptions and Errors
Well-behaved COM server objects don't usually throw exceptions back to their clients , but they can. So, to be cautious it's a good idea to put most of your COM- related code in a try block and follow it with a catch block for COM errors. COM errors are encapsulated in the Visual C++ compiler helper class _com_error.
Other than that, you need to know about HRESULT. This is a 32-bit data structure used to return status information about calls to methods in the COM APIs. You can't just check on a nonzero return value to see whether or not a call failed; it is a more complex data structure than that. Visual C++ provides some macros to check on HRESULT. I use FAILED and SUCCEEDED. Both return booleans. You'll see that the book's code also checks on some more specific return values associated with the MSXML DOM implementation.
If you want to do by-the-book COM programming, you will check for the HRESULT return from every method call to a COM interface. We could do this, but the code would be littered with status checks that in 99.9 percent of the cases would never execute the failure branch. I instead rely primarily on schema validation to enforce some expectations about the input XML documents we'll be processing and check for NULL pointers where applicable .
COM Classes and Data Types for C++
This is a brief list of the nonnative C++ COM data types and helper classes you are likely to have to deal with when using MSXML.
If you find something in the book's code or in the MSXML sample code that isn't listed here, you can usually learn more about it by performing an index or search in the MSDN Library (available online at http://msdn.microsoft.com/library or from online help in Visual Studio).