tags:

views:

598

answers:

4

I'm at a loss for where to get the best information about the meaning, likely causes, and possible solutions to resolve COM errors when all you have is the HRESULT.

Searching Google for terms like '80004027' is just about useless as it sends you to random discussion groups where 90% of the time, the question 'What does 80004027 mean?' is not answered.

What is a good resource for this? Why isn't MSDN the top Google result?

A: 

Structure of COM Error Code

Second in Google results for COM Error Code.

Prakash
A: 

Good link from Prakash (I wasn't aware of the RCNr stuff - I thought those bytes were part of the facility - but that's only true in 16 bit Windows it seems.)

Often these unknown codes are specific to the interface/component you're using. The facility would be set to FACILITY_ITF. I have an old program HRPlus (link?) that parses HRESULTs.

Aardvark
+4  A: 

Error Lookup (ErrLook.exe) in your %PROGRAMFILES%[Some version of Visual Studio]\Tools Common7\ folder will give you the error message often, but not always:

    |---------------------------------------------------|
    | [] Error Lookup                                   |
    |---------------------------------------------------|
    |   Value: [0x80004027]                             |
    |                                                   |
    |   Error Message                                   |
    |   +---------------------------------------------+ |
    |   |The component or application containing the  | |
    |   |component has been disabled                  | |
    |   |                                             | |
    |   +---------------------------------------------+ |
    |   [Modules...]    [Look up]    [Close]    [Help]  |
    |----------------------------------------------------

If this doesn't work, you might follow some ideas from here: http://blogs.msdn.com/oldnewthing/archive/2008/09/01/8914664.aspx

(Error Lookup simply calls FormatMessage() with the FORMAT_MESSAGE_FROM_SYSTEM flag)

If the COM error is not a system error, you might also have to check the documentation of the component that threw the error.

If you are catching the error in code, you can hope that the component implements rich errors (GetErrorInfo(), same as the Err object in VB) so you can get a full message describing the problem.

Euro Micelli
+4  A: 

I always use WinError.h. That has the vast majority of Windows error codes of all sorts.

A key indicator to look out for is the Facility part of the code: the second most-significant byte. That is, 0x80nnmmmm, where nn is the Facility. That tells you which component generated the code. Anything with a facility of 7 is a Windows error code repackaged as an HRESULT, and you should convert the low word to decimal and look it up in WinError.h. There are also error ranges that appear in their own headers (e.g. anything from 12000 - 12999 is a WinInet error code and you should look it up in WinInet.h).

Looking up the error code will give you the symbolic name, which might be found in more documentation than the code itself or the wording of the error message.

FACILITY_ITF (which has the value 4, so these HRESULTs start 0x8004) indicates that the error is defined by the interface you're using; you'll have to check with that interface to find out what it means.

Finally, COM also offers the interface IErrorInfo to retrieve extended error information: call GetErrorInfo to retrieve the error object. You'll have to query for ISupportErrorInfo and call that interface's InterfaceSupportsErrorInfo method to determine whether the interface you called actually set the error object (and of course, if it was template code, it could be lying).

Mike Dimmick
This is what I always used to use... basically ErrorLookup reads this file!
Shaun Austin