HRESULT

共通の値 (Common Values)

名前 説明
16進 10進
S_OK Operation successful 0x00000000 -4294967296
E_ABORT Operation aborted 0x80004004 -2147467260
E_ACCESSDENIED General access denied error 0x80070005 -2147024891
E_FAIL Unspecified failure 0x80004005 -2147467259
E_HANDLE Handle that is not valid 0x80070006 -2147024890
E_INVALIDARG One or more arguments are not valid 0x80070057 -2147024809
E_NOINTERFACE No such interface supported 0x80004002 -2147467262
E_NOTIMPL Not implemented 0x80004001 -2147467263
E_OUTOFMEMORY Failed to allocate necessary memory 0x8007000E -2147024882
E_POINTER Pointer that is not valid 0x80004003 -2147467261
E_UNEXPECTED Unexpected failure 0x8000FFFF -2147418113
Common HRESULT Values | Microsoft Learn

これ以外の値は、[MS-ERREF]: 2.1.1 HRESULT Values | MSDNに詳細があります。

System.HResults

区分 名前
16進 10進
  Configuration 0x80131902 -2146232062
Xml Xml 0x80131940 -2146232000
Xml XmlSchema 0x80131941 -2146231999
Xml XmlXslt 0x80131942 -2146231998
Xml XmlXPath 0x80131943 -2146231997
DataSet Data 0x80131920 -2146232032
DataSet DataDeletedRowInaccessible 0x80131921 -2146232031
DataSet DataDuplicateName 0x80131922 -2146232030
DataSet DataInRowChangingEvent 0x80131923 -2146232029
DataSet DataInvalidConstraint 0x80131924 -2146232028
DataSet DataMissingPrimaryKey 0x80131925 -2146232027
DataSet DataNoNullAllowed 0x80131926 -2146232026
DataSet DataReadOnly 0x80131927 -2146232025
DataSet DataRowNotInTable 0x80131928 -2146232024
DataSet DataVersionNotFound 0x80131929 -2146232023
DataSet DataConstraint 0x8013192A -2146232022
DataSet StrongTyping 0x8013192B -2146232021
Managed Providers SqlType 0x80131930 -2146232016
Managed Providers SqlNullValue 0x80131931 -2146232015
Managed Providers SqlTruncate 0x80131932 -2146232014
Managed Providers AdapterMapping 0x80131933 -2146232013
Managed Providers DataAdapter 0x80131934 -2146232012
Managed Providers DBConcurrency 0x80131935 -2146232011
Managed Providers OperationAborted 0x80131936 -2146232010
Managed Providers InvalidUdt 0x80131937 -2146232009
Managed Providers Metadata 0x80131939 -2146232007
Managed Providers InvalidQuery 0x8013193A -2146232006
Managed Providers CommandCompilation 0x8013193B -2146232005
Managed Providers CommandExecution 0x8013193C -2146232004
Managed Providers SqlException 0x80131904 -2146232060
Managed Providers OdbcException 0x80131937 -2146232009
Managed Providers OracleException 0x80131938 -2146232008
Managed Providers ConnectionPlanException 0x8013193d -2146232003
Configuration encryption NteBadKeySet 0x80090016 -2146893802
Win32 Win32AccessDenied 0x80070005 -2147024891
Win32 Win32InvalidHandle 0x80070006 -2147024890
Win32 License 0x80131901 -2146232063
Win32 InternalBufferOverflow 0x80131905 -2146232059
Win32 ServiceControllerTimeout 0x80131906 -2146232058
Win32 Install 0x80131907 -2146232057
Win32 EFail 0x80004005 -2147467259
hresults.cs
名前
16進 10進
RO_E_CLOSED 0x80000013 -2147483629
E_BOUNDS 0x8000000B -2147483637
E_CHANGED_STATE 0x8000000C -2147483636
E_FAIL 0x80004005 -2147467259
E_POINTER 0x80004003 -2147467261
E_NOTIMPL 0x80004001 -2147467263
REGDB_E_CLASSNOTREG 0x80040154 -2147221164
COR_E_AMBIGUOUSMATCH 0x8000211D -2147475171
COR_E_APPDOMAINUNLOADED 0x80131014 -2146234348
COR_E_APPLICATION 0x80131600 -2146232832
COR_E_ARGUMENT 0x80070057 -2147024809
COR_E_ARGUMENTOUTOFRANGE 0x80131502 -2146233086
COR_E_ARITHMETIC 0x80070216 -2147024362
COR_E_ARRAYTYPEMISMATCH 0x80131503 -2146233085
COR_E_BADIMAGEFORMAT 0x8007000B -2147024885
COR_E_TYPEUNLOADED 0x80131013 -2146234349
COR_E_CANNOTUNLOADAPPDOMAIN 0x80131015 -2146234347
COR_E_COMEMULATE 0x80131535 -2146233035
COR_E_CONTEXTMARSHAL 0x80131504 -2146233084
COR_E_DATAMISALIGNED 0x80131541 -2146233023
COR_E_TIMEOUT 0x80131505 -2146233083
COR_E_CUSTOMATTRIBUTEFORMAT 0x80131605 -2146232827
COR_E_DIVIDEBYZERO 0x80020012 -2147352558
COR_E_DUPLICATEWAITOBJECT 0x80131529 -2146233047
COR_E_EXCEPTION 0x80131500 -2146233088
COR_E_EXECUTIONENGINE 0x80131506 -2146233082
COR_E_FIELDACCESS 0x80131507 -2146233081
COR_E_FORMAT 0x80131537 -2146233033
COR_E_INDEXOUTOFRANGE 0x80131508 -2146233080
COR_E_INSUFFICIENTMEMORY 0x8013153D -2146233027
COR_E_INSUFFICIENTEXECUTIONSTACK 0x80131578 -2146232968
COR_E_INVALIDCAST 0x80004002 -2147467262
COR_E_INVALIDCOMOBJECT 0x80131527 -2146233049
COR_E_INVALIDFILTERCRITERIA 0x80131601 -2146232831
COR_E_INVALIDOLEVARIANTTYPE 0x80131531 -2146233039
COR_E_INVALIDOPERATION 0x80131509 -2146233079
COR_E_INVALIDPROGRAM 0x8013153A -2146233030
COR_E_KEYNOTFOUND 0x80131577 -2146232969
COR_E_MARSHALDIRECTIVE 0x80131535 -2146233035
COR_E_MEMBERACCESS 0x8013151A -2146233062
COR_E_METHODACCESS 0x80131510 -2146233072
COR_E_MISSINGFIELD 0x80131511 -2146233071
COR_E_MISSINGMANIFESTRESOURCE 0x80131532 -2146233038
COR_E_MISSINGMEMBER 0x80131512 -2146233070
COR_E_MISSINGMETHOD 0x80131513 -2146233069
COR_E_MISSINGSATELLITEASSEMBLY 0x80131536 -2146233034
COR_E_MULTICASTNOTSUPPORTED 0x80131514 -2146233068
COR_E_NOTFINITENUMBER 0x80131528 -2146233048
COR_E_PLATFORMNOTSUPPORTED 0x80131539 -2146233031
COR_E_NOTSUPPORTED 0x80131515 -2146233067
COR_E_NULLREFERENCE 0x80004003 -2147467261
COR_E_OBJECTDISPOSED 0x80131622 -2146232798
COR_E_OPERATIONCANCELED 0x8013153B -2146233029
COR_E_OUTOFMEMORY 0x8007000E -2147024882
COR_E_OVERFLOW 0x80131516 -2146233066
COR_E_RANK 0x80131517 -2146233065
COR_E_REFLECTIONTYPELOAD 0x80131602 -2146232830
COR_E_RUNTIMEWRAPPED 0x8013153E -2146233026
COR_E_SAFEARRAYRANKMISMATCH 0x80131538 -2146233032
COR_E_SAFEARRAYTYPEMISMATCH 0x80131533 -2146233037
COR_E_SAFEHANDLEMISSINGATTRIBUTE 0x80131623 -2146232797
COR_E_SECURITY 0x8013150A -2146233078
COR_E_SERIALIZATION 0x8013150C -2146233076
COR_E_SEMAPHOREFULL 0x8013152B -2146233045
COR_E_WAITHANDLECANNOTBEOPENED 0x8013152C -2146233044
COR_E_ABANDONEDMUTEX 0x8013152D -2146233043
COR_E_STACKOVERFLOW 0x800703E9 -2147023895
COR_E_SYNCHRONIZATIONLOCK 0x80131518 -2146233064
COR_E_SYSTEM 0x80131501 -2146233087
COR_E_TARGET 0x80131603 -2146232829
COR_E_TARGETINVOCATION 0x80131604 -2146232828
COR_E_TARGETPARAMCOUNT 0x8002000e -2147352562
COR_E_THREADABORTED 0x80131530 -2146233040
COR_E_THREADINTERRUPTED 0x80131519 -2146233063
COR_E_THREADSTATE 0x80131520 -2146233056
COR_E_THREADSTOP 0x80131521 -2146233055
COR_E_THREADSTART 0x80131525 -2146233051
COR_E_TYPEACCESS 0x80131543 -2146233021
COR_E_TYPEINITIALIZATION 0x80131534 -2146233036
COR_E_TYPELOAD 0x80131522 -2146233054
COR_E_ENTRYPOINTNOTFOUND 0x80131523 -2146233053
COR_E_DLLNOTFOUND 0x80131524 -2146233052
COR_E_UNAUTHORIZEDACCESS 0x80070005 -2147024891
COR_E_UNSUPPORTEDFORMAT 0x80131523 -2146233053
COR_E_VERIFICATION 0x8013150D -2146233075
COR_E_HOSTPROTECTION 0x80131640 -2146232768
CORSEC_E_MIN_GRANT_FAIL 0x80131417 -2146233321
CORSEC_E_NO_EXEC_PERM 0x80131418 -2146233320
CORSEC_E_POLICY_EXCEPTION 0x80131416 -2146233322
CORSEC_E_XMLSYNTAX 0x80131418 -2146233320
NTE_FAIL 0x80090020 -2146893792
CORSEC_E_CRYPTO 0x80131430 -2146233296
CORSEC_E_CRYPTO_UNEX_OPER 0x80131431 -2146233295
DISP_E_OVERFLOW 0x8002000a -2147352566
FUSION_E_REF_DEF_MISMATCH 0x80131040 -2146234304
FUSION_E_INVALID_NAME 0x80131047 -2146234297
TYPE_E_TYPEMISMATCH 0x80028ca0 -2147316576
__hresults.cs

エラーメッセージの取得

C++

_com_errorクラスのErrorMessage()から取得できます。c++ - Is there a way to get the string representation of HRESULT value using win API? - Stack Overflow

#include <comdef.h>
HRESULT hr = S_OK;

_com_error error(hr);
LPCTSTR message = error.ErrorMessage(); // この操作を正しく終了しました。
_com_error Class | Microsoft Learn

C#

Marshal.GetExceptionForHR()でHRESULTエラー コードに対応するExceptionクラスを得て、そのMessageプロパティから取得できます。How to fetch the message string from Win32 provided HRESULT C# - Stack Overflow

Exception ex = Marshal.GetExceptionForHR(e.HResult);
string message = ex.Message;
Marshal.GetExceptionForHR メソッド (System.Runtime.InteropServices) | Microsoft Learn

また新しい例外クラスを作成し、HRESULT に割り当てるには - 方法: HRESULT に例外を割り当てる - .NET Framework | Microsoft Learnに、HRESULTと.NETの例外との対応表があります。

複数の技術系サイトから、まとめて検索