我在哪里可以找到所有 Windows 错误代码的列表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1081276/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where can I find a list of all windows error codes?
提问by
In a previous question, I asked what it meant when my program returned an obscure value like
在上一个问题中,我问过当我的程序返回一个像
-1073741819
Well, now I'm getting another large return value,
好吧,现在我得到了另一个大的回报值,
-1073740777
And I would like to know if there is some list of all of these values and what they mean sopmewhere?
我想知道是否有一些所有这些值的列表以及它们在某些地方的含义?
采纳答案by Greg Hewgill
Generally you will get better search results if you print out the error number in hex, instead of signed decimal form.
通常,如果您以十六进制而不是带符号的十进制形式打印错误编号,您将获得更好的搜索结果。
For example, your first error is -1073741819 which can also be represented by 0xC0000005 in hex. This is an "access violation" error as google will quickly tell you.
例如,您的第一个错误是 -1073741819,它也可以用十六进制的 0xC0000005 表示。这是一个“访问冲突”错误,因为谷歌会很快告诉你。
回答by Jared Oberhaus
Because the Windows error code system is extensible, there is no single place to look up all possible Windows error codes. However, you can start with:
因为 Windows 错误代码系统是可扩展的,所以没有一个地方可以查找所有可能的 Windows 错误代码。但是,您可以从以下内容开始:
- Study the Structure of COM Error Codes. Sometimes knowing what facility an error comes from can help you discover what header file it comes from.
- Visual Studio, since at least 2003, includes an
ERRLOOK
tool. Try that first if you're using Visual Studio. - Many of the codes you'll encounter are in
Winerror.h
. I've included a link to MSDN that contains the contents of that header file. Or you can look at the error code listing by number on thispage. - Ideally you know what function returned the code, and then you can lookup the function on MSDN and look at all the possible return values. Of course, you'll need to refer to
Winerror.h
, or an another header file to get the actual values. - You can
find
(like Unixgrep
) in theInclude
directory of the platform SDK for either the hex value of the entire error code, or the decimal value of just the code section--that is, the lower 16 bits. UseHRESULT_CODE
to extract that. See the Structure of COM Error Codes above. - There are a few error lookup tools where you can paste in a value and it looks it up in its database and tells you what it means. Look hereand here.
- Google. Use the full hex value. Sometimes you'll find very useful information, or at least clues.
- 研究COM 错误代码的结构。有时知道错误来自哪个工具可以帮助您发现它来自哪个头文件。
- 至少从 2003 年开始,Visual Studio 就包含了一个
ERRLOOK
工具。如果您使用的是 Visual Studio,请先尝试。 - 您将遇到的许多代码都在
Winerror.h
. 我已经包含了一个指向 MSDN 的链接,其中包含该头文件的内容。或者您可以查看此页面上按编号列出的错误代码。 - 理想情况下,您知道返回代码的是哪个函数,然后您可以在 MSDN 上查找该函数并查看所有可能的返回值。当然,您需要参考
Winerror.h
或另一个头文件来获取实际值。 - 您可以
find
(如 Unixgrep
)在Include
平台 SDK的目录中获取整个错误代码的十六进制值,或仅代码部分的十进制值——即低 16 位。使用HRESULT_CODE
来提取。请参阅上面的 COM 错误代码的结构。 - 有一些错误查找工具,您可以在其中粘贴一个值,然后它会在其数据库中查找它并告诉您它的含义。看这里和这里。
- 谷歌。使用完整的十六进制值。有时您会发现非常有用的信息,或者至少是线索。
回答by ChrisW
Many of them (but not I think the ones related to COM) are in a header file named winerror.h.
其中许多(但不是我认为与 COM 相关的)都在名为winerror.h的头文件中。
In (some versions of) Visual Studio, under the 'Tools
' menu, you might find an menu item named 'Error Lookup...
'.
在(某些版本的)Visual Studio 中,在“ Tools
”菜单下,您可能会找到名为“ Error Lookup...
”的菜单项。
回答by Robert Harvey
Well there's a bunch of them here,
嗯,这里有很多,
http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx
But when I get one like your example I just Google the number.
但是当我得到一个像你的例子时,我只是用谷歌搜索这个数字。
回答by josh poley
NTSTATUS
状态
NTSTATUS*covers a range of facilities
FACILITY_URT(0x013) *CLR exceptions
NTSTATUS*涵盖一系列设施
FACILITY_URT(0x013) *CLR 异常
HRESULTS
结果
FACILITY_NULL(0x000)
FACILITY_RPC(0x001)
FACILITY_DISPATCH(0x002)
FACILITY_RPC_STUBS(0x003)
FACILITY_USER(0x004) *multiple libraries can reuse the same error code
FACILITY_MCA_ERROR_CODE(0x005)
FACILITY_WIN32, MSDN(0x007) *standard WINAPI error codes
FACILITY_WINDOWS(0x008)
FACILITY_SECURITY(0x009)
FACILITY_CERT(0x00B)
FACILITY_INTERNET(0x00C)
FACILITY_MEDIASERVER(0x00D)
FACILITY_MSMQ(0x00E)
FACILITY_SETUPAPI(0x00F)
FACILITY_SCARD(0x010)
FACILITY_COMPLUS(0x011)
FACILITY_HTTP(0x019)
FACILITY_USERMODE_FILTER_MANAGER(0x01F)
FACILITY_WINDOWSUPDATE(0x024)
FACILITY_GRAPHICS(0x026)
FACILITY_NAP(0x027)
FACILITY_INK(0x028)
FACILITY_TPM_SOFTWARE(0x029)
FACILITY_UI(0x02A)
FACILITY_PLA(0x030)
FACILITY_FVE(0x031)
FACILITY_FWP(0x032)
FACILITY_WINRM(0x033)
FACILITY_NDIS(0x034)
FACILITY_USERMODE_HYPERVISOR(0x035)
FACILITY_USERMODE_VIRTUALIZATION(0x037)
FACILITY_USERMODE_VOLMGR(0x038)
FACILITY_BCD(0x039)
FACILITY_USERMODE_VHD(0x03A)
FACILITY_SDIAG(0x03C)
FACILITY_WEBSERVICES(0x03D)
FACILITY_WPN(0x03E)
FACILITY_MBN(0x054)
FACILITY_P2P(0x063)
FACILITY_BLUETOOTH_ATT(0x065)
FACILITY_AUDIO(0x066)
FACILITY_IMAPI2(0x0AA)
FACILITY_RTC_INTERFACE(0x0EE)
FACILITY_SIP_STATUS_CODE(0x0EF)
FACILITY_PINT_STATUS_CODE(0x0F0)
FACILITY_MAX_WDSTPTMGMT(0x110)
FACILITY_WDSMCSERVER(0x121)
FACILITY_MAX_WDSMC(0x122)
FACILITY_MAX_WDSCP(0x125)
FACILITY_BACKUP(0x7FF)
FACILITY_NTDSB(0x800)
FACILITY_DIRECT3D10(0x879)
FACILITY_DXGI(0x87A)
FACILITY_DXGI_DDI(0x87B)
FACILITY_DIRECT3D11(0x87C)
FACILITY_DWRITE(0x898)
FACILITY_D2D(0x899)
FACILITY_DEFRAG(0x900)
FACILITY_ONLINE_ID(0xA02)
FACILITY_NULL(0x000的)
FACILITY_RPC(0×001)
FACILITY_DISPATCH(0x002)
FACILITY_RPC_STUBS(0x003)
FACILITY_USER(为0x004)*多个库可以重复使用相同的错误代码
FACILITY_MCA_ERROR_CODE(0x005)
FACILITY_WIN32,MSDN(0x007)*标准WINAPI错误代码
FACILITY_WINDOWS(量0x008)
FACILITY_SECURITY( 0x009)
FACILITY_CERT(0x00B)
FACILITY_INTERNET(0x00C)
FACILITY_MEDIASERVER(0x00D)
FACILITY_MSMQ(0x00E)
FACILITY_SETUPAPI(0x00F)
FACILITY_SCARD(0x010)
FACILITY_COMPLUS(0x011)
FACILITY_HTTP(0x019)
FACILITY_USERMODE_FILTER_MANAGER(0x01F)
FACILITY_WINDOWSUPDATE(量0x024)
FACILITY_GRAPHICS(0x026)
FACILITY_NAP(0×027)
FACILITY_INK(量0x028)
FACILITY_TPM_SOFTWARE(0x029)
FACILITY_UI(0x02A)
FACILITY_PLA(量0x030)
FACILITY_FVE(0x031)
FACILITY_FWP(0x032)
FACILITY_WINRM( 0x033)
FACILITY_NDIS(0x034)
FACILITY_USERMODE_HYPERVISOR(0x035)
FACILITY_USERMODE_VIRTUALIZATION(0x037)
FACILITY_USERMODE_VOLMGR(量0x038)
FACILITY_BCD(0x039)
FACILITY_USERMODE_VHD(0x03A)
FACILITY_SDIAG(量0x03C)
FACILITY_WEBSERVICES(0x03D)
FACILITY_WPN(0x03E)
FACILITY_MBN(量0x054)
FACILITY_P2P(0x063)
FACILITY_BLUETOOTH_ATT(0x065)
FACILITY_AUDIO(0x066)
FACILITY_IMAPI2(0x0AA)
FACILITY_RTC_INTERFACE(0x0EE)
FACILITY_SIP_STATUS_CODE(0x0EF )
FACILITY_PINT_STATUS_CODE(0x0F0)
FACILITY_MAX_WDSTPTMGMT(0x110)
FACILITY_WDSMCSERVER(0x121)
FACILITY_MAX_WDSMC(0x122)
FACILITY_MAX_WDSCP(0x125)
FACILITY_BACKUP(0x7FF)
FACILITY_NTDSB(为0x800)
FACILITY_DIRECT3D10(0x879)
FACILITY_DXGI(0x87A)
FACILITY_DXGI_DDI(0x87B)
FACILITY_DIRECT3D11(0x87C)
FACILITY_DWRITE(0x898)
FACILITY_D2D(0x899)
FACILITY_DEFRAG(0x900)
FACILITY_ONLINE_ID(0xA02)
Bug Checks
错误检查
Bug Check Code Reference*aka Blue Screens
错误检查代码参考*aka 蓝屏
回答by Simon Mourier
Here is a 100% free online tool "MagnumDB" for "Magical Number Database" that contains about 350,000 constants (integers, strings, guids, etc.) parsed from the whole Windows SDK files (~6,000 files), that you can query by value and by name. Disclaimer: I wrote it after years of searching for constants, names, guids...
这是一个 100% 免费的在线工具“ MagnumDB”,用于“神奇数字数据库”,其中包含从整个 Windows SDK 文件(约 6,000 个文件)解析的大约 350,000 个常量(整数、字符串、guid 等),您可以通过值和名称。免责声明:我是在多年寻找常量、名称、指南之后写的......
Here is the result for -1073741819which maps to 3 different constants (with the same value and the same meaning) defined in 3 different files, the most common being STATUS_ACCESS_VIOLATION
.
这是-1073741819的结果,它映射到 3 个不同的文件中定义的 3 个不同的常量(具有相同的值和相同的含义),最常见的是STATUS_ACCESS_VIOLATION
.
And for -1073740777which is STATUS_INVALID_CRUNTIME_PARAMETER
defined in winnt.h
.
对于-1073740777中STATUS_INVALID_CRUNTIME_PARAMETER
定义的winnt.h
.
It supports integers, signed integers, unsigned integers, hexadecimal notation, and also raw text searches. It also knows the value of constants that are defined by operations (like c2 = c1 + 1).
它支持整数、有符号整数、无符号整数、十六进制表示法以及原始文本搜索。它还知道由操作定义的常量的值(如 c2 = c1 + 1)。
回答by rboy
Here's a class in C#
to help you convert the error codesto string
:
下面是一个类C#
来帮助你转换的错误代码到string
:
public static class WinErrors
{
#region definitions
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr LocalFree(IntPtr hMem);
[DllImport("kernel32.dll", SetLastError = true)]
static extern int FormatMessage(FormatMessageFlags dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, ref IntPtr lpBuffer, uint nSize, IntPtr Arguments);
[Flags]
private enum FormatMessageFlags : uint
{
FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100,
FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200,
FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000,
FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000,
FORMAT_MESSAGE_FROM_HMODULE = 0x00000800,
FORMAT_MESSAGE_FROM_STRING = 0x00000400,
}
#endregion
/// <summary>
/// Gets a user friendly string message for a system error code
/// </summary>
/// <param name="errorCode">System error code</param>
/// <returns>Error string</returns>
public static string GetSystemMessage(int errorCode)
{
try
{
IntPtr lpMsgBuf = IntPtr.Zero;
int dwChars = FormatMessage(
FormatMessageFlags.FORMAT_MESSAGE_ALLOCATE_BUFFER | FormatMessageFlags.FORMAT_MESSAGE_FROM_SYSTEM | FormatMessageFlags.FORMAT_MESSAGE_IGNORE_INSERTS,
IntPtr.Zero,
(uint) errorCode,
0, // Default language
ref lpMsgBuf,
0,
IntPtr.Zero);
if (dwChars == 0)
{
// Handle the error.
int le = Marshal.GetLastWin32Error();
return "Unable to get error code string from System - Error " + le.ToString();
}
string sRet = Marshal.PtrToStringAnsi(lpMsgBuf);
// Free the buffer.
lpMsgBuf = LocalFree(lpMsgBuf);
return sRet;
}
catch (Exception e)
{
return "Unable to get error code string from System -> " + e.ToString();
}
}
}