COM

The situation didn’t get much better in the Component Object Model. Again, integral values are used to report errors, now hidden behind a typedef called HRESULT (which originally stood for handle to a result). One thing we should grant COM is adding a tiny little bit more structure to error handling by introducing style guidelines on the way functions should report errors. In Win32, each function had its own habits, some of which returned an error code as a return value, whereas others relied on GetLastError facilities. But guidelines are just that: guidelines. Occasionally, you will find COM APIs that don’t follow those guidelines.

Because the typical COM API design is to have functions return an HRESULT, resulting checking macros such as ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.