The great thing about naming conventions is that not everybody will follow them

Raymond Chen

Raymond

The naming convention for HRESULT is «facility»_«severity»_«name», where the facility portion (and the underscore) is omitted if the facility is FACILITY_NULL or FACILITY_WIN32.
Good luck finding anybody who follows this naming convention.
Okay, fine, if you look closely you might be able to find some people who do.

COM  CO_E_NOTINITIALIZED
CO_S_MACHINENAMENOTFOUND
Structured storage  STG_E_SHAREVIOLATION
STG_S_CONVERTED
SETUPAPI  SPAPI_E_EXPECTED_SECTION_NAME
Data and view  DV_E_TYMED
DV_E_FORMATETC
Class factory  CLASS_E_NOAGGREGATION
Class registry  REGDB_E_CLASSNOTREG
OLEDB  DB_E_DELETEDROW

Actually, I guess I was a bit too pessimistic when I said nobody follows it. It seems that the majority of Windows components do follow this convention, although there are some notable exceptions.

DirectDraw  DDERR_UNSUPPORTEDFORMAT
ADSI  E_ADS_INVALID_DOMAIN_OBJECT

There are also some people who decided to confuse matters further by using the HRESULT convention for error codes returned by GetLastError()!

RPC  RPC_S_OBJECT_NOT_FOUND
SmartCard  SEC_E_SMARTCARD_CERT_REVOKED
Task scheduler  SCHED_E_SERVICE_NOT_LOCALSYSTEM
Winsock  WSA_E_NO_MORE

I apologize for the confusion this has caused.

Pre-emptive clarifying remark: The examples given in this article are merely illustrative and are not intended to be comprehensive.

0 comments

Comments are closed.