{"id":16943,"date":"2009-08-28T10:00:00","date_gmt":"2009-08-28T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2009\/08\/28\/the-great-thing-about-naming-conventions-is-that-not-everybody-will-follow-them\/"},"modified":"2009-08-28T10:00:00","modified_gmt":"2009-08-28T10:00:00","slug":"the-great-thing-about-naming-conventions-is-that-not-everybody-will-follow-them","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20090828-00\/?p=16943","title":{"rendered":"The great thing about naming conventions is that not everybody will follow them"},"content":{"rendered":"<p>The naming convention for <code>HRESULT<\/code> is &laquo;facility&raquo;<code>_<\/code>&laquo;severity&raquo;<code>_<\/code>&laquo;name&raquo;, where the facility portion (and the underscore) is omitted if the facility is <code>FACILITY_NULL<\/code> or <code>FACILITY_WIN32<\/code>.\n Good luck finding anybody who follows this naming convention.\n Okay, fine, if you look closely you might be able to find some people who do.<\/p>\n<table cellpadding=\"0\" cellspacing=\"0\">\n<tr>\n<th rowspan=\"2\" valign=\"baseline\" align=\"left\">COM&nbsp;&nbsp;<\/th>\n<td align=\"right\">CO_<\/td>\n<td>E_<\/td>\n<td>NOTINITIALIZED<\/td>\n<\/tr>\n<tr>\n<td align=\"right\">CO_<\/td>\n<td>S_<\/td>\n<td>MACHINENAMENOTFOUND<\/td>\n<\/tr>\n<tr>\n<th rowspan=\"2\" valign=\"baseline\" align=\"left\">Structured storage&nbsp;&nbsp;<\/th>\n<td align=\"right\">STG_<\/td>\n<td>E_<\/td>\n<td>SHAREVIOLATION<\/td>\n<\/tr>\n<tr>\n<td align=\"right\">STG_<\/td>\n<td>S_<\/td>\n<td>CONVERTED<\/td>\n<\/tr>\n<tr>\n<th valign=\"baseline\" align=\"left\">SETUPAPI&nbsp;&nbsp;<\/th>\n<td align=\"right\">SPAPI_<\/td>\n<td>E_<\/td>\n<td>EXPECTED_SECTION_NAME<\/td>\n<\/tr>\n<tr>\n<th rowspan=\"2\" valign=\"baseline\" align=\"left\">Data and view&nbsp;&nbsp;<\/th>\n<td align=\"right\">DV_<\/td>\n<td>E_<\/td>\n<td>TYMED<\/td>\n<\/tr>\n<tr>\n<td align=\"right\">DV_<\/td>\n<td>E_<\/td>\n<td>FORMATETC<\/td>\n<\/tr>\n<tr>\n<th valign=\"baseline\" align=\"left\">Class factory&nbsp;&nbsp;<\/th>\n<td align=\"right\">CLASS_<\/td>\n<td>E_<\/td>\n<td>NOAGGREGATION<\/td>\n<\/tr>\n<tr>\n<th valign=\"baseline\" align=\"left\">Class registry&nbsp;&nbsp;<\/th>\n<td align=\"right\">REGDB_<\/td>\n<td>E_<\/td>\n<td>CLASSNOTREG<\/td>\n<\/tr>\n<tr>\n<th rowspan=\"2\" valign=\"baseline\" align=\"left\">OLEDB&nbsp;&nbsp;<\/th>\n<td align=\"right\">DB_<\/td>\n<td>E_<\/td>\n<td>DELETEDROW<\/td>\n<\/tr>\n<\/table>\n<p> Actually, I guess I was a bit too pessimistic when I said <i>nobody<\/i> follows it. It seems that the majority of Windows components do follow this convention, although there are some notable exceptions.<\/p>\n<table>\n<tr>\n<th valign=\"baseline\" align=\"left\">DirectDraw&nbsp;&nbsp;<\/th>\n<td>DDERR_UNSUPPORTEDFORMAT<\/td>\n<\/tr>\n<tr>\n<th valign=\"baseline\" align=\"left\">ADSI&nbsp;&nbsp;<\/th>\n<td>E_ADS_INVALID_DOMAIN_OBJECT<\/td>\n<\/tr>\n<\/table>\n<p> There are also some people who decided to confuse matters further by using the <code>HRESULT<\/code> convention for error codes returned by <code>GetLastError()<\/code>!<\/p>\n<table>\n<tr>\n<th valign=\"baseline\" align=\"left\">RPC&nbsp;&nbsp;<\/th>\n<td>RPC_S_OBJECT_NOT_FOUND<\/td>\n<\/tr>\n<tr>\n<th valign=\"baseline\" align=\"left\">SmartCard&nbsp;&nbsp;<\/th>\n<td>SEC_E_SMARTCARD_CERT_REVOKED<\/td>\n<\/tr>\n<tr>\n<th valign=\"baseline\" align=\"left\">Task scheduler&nbsp;&nbsp;<\/th>\n<td>SCHED_E_SERVICE_NOT_LOCALSYSTEM<\/td>\n<\/tr>\n<tr>\n<th valign=\"baseline\" align=\"left\">Winsock&nbsp;&nbsp;<\/th>\n<td>WSA_E_NO_MORE<\/td>\n<\/tr>\n<\/table>\n<p> I apologize for the confusion this has caused.<\/p>\n<p> <b>Pre-emptive clarifying remark<\/b>: The examples given in this article are <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2009\/06\/18\/9771135.aspx#9791094\"> merely illustrative and are not intended to be comprehensive<\/a>. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>The naming convention for HRESULT is &laquo;facility&raquo;_&laquo;severity&raquo;_&laquo;name&raquo;, 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&nbsp;&nbsp; CO_ E_ NOTINITIALIZED CO_ S_ MACHINENAMENOTFOUND [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-16943","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>The naming convention for HRESULT is &laquo;facility&raquo;_&laquo;severity&raquo;_&laquo;name&raquo;, 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&nbsp;&nbsp; CO_ E_ NOTINITIALIZED CO_ S_ MACHINENAMENOTFOUND [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/16943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=16943"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/16943\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=16943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=16943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=16943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}