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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.