HRESULT 异常

发布于 2024-08-03 08:15:38 字数 62 浏览 3 评论 0原文

是否有任何解释错误代码的列表。 Eks:HRESULT:0x81070215 没有告诉我任何错误时发生了什么?

Is there any lists where the error codes are explained. Eks: HRESULT: 0x81070215 does not tell me enything about what when wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

欲拥i 2024-08-10 08:15:38
WinError.h 

我的计算机上有以下路径,您的计算机也将类似:

C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\WinError.h

顺便说一句,如果您安装了 Visual Studio,则有一个名为“错误查找”的可用工具。转到 Visual Studio,工具 -> 错误查找,您可以在其中输入任何 HRESULT 代码来获取其描述。您也可以从此位置下载ErrorLookup。

WinError.h 

I have this at the following path on my machine, yours will be similar as well:

C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\WinError.h

BTW, if you have Visual Studio installed, then there is a tool available named 'Error Lookup'. Go to Visual Studio, Tools->Error Lookup and in it you can put any HRESULT code to get it's description. You can download ErrorLookup from this location as well.

云仙小弟 2024-08-10 08:15:38

HRESULT 代码是由导致它们发生的代码定义的,因此没有唯一的列表 - 它取决于服务器代码的含义。通常,您需要查看当前线程的错误信息 ,并查看随其传递的附加信息,以便使其有意义。

The HRESULT codes are defined by the code that is causing them to happen, so there is no unique list - it depends on the server code as to what they mean. Normally, you want to look at the error info for the current thread, and see what additional information is passed along with it, in order for it to make sense.

世界等同你 2024-08-10 08:15:38

VS的工具菜单中有一个错误查找工具(Tools->Error Lookup),你也可以在这里找到工具

C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\errlook.exe

There is an error look tool in VS's Tools menu (Tools->Error Lookup), also you can find tool here

C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\errlook.exe
混浊又暗下来 2024-08-10 08:15:38

一些更常见的错误消息可以通过 Windows 内置工具(如 certutilnet )查找,

PS C:\> net helpmsg 5

Access denied

PS C:\> certutil -error '0x80070005'
0x80070005 (WIN32: 5 ERROR_ACCESS_DENIED) -- 2147942405 (-2147024891)
Text of the error message: Access denied

因为问题被标记为 .net:也是元帅。 GetExceptionForHR 可用于将一些 HRESULTS 转换为有用的 .net 异常。
也可以从 Powershell 调用:
PS C:\> [System.Runtime.InteropServices.Marshal]::GetExceptionForHR(0x81070215, -1)
遗憾的是,此方法也没有为请求的值 0x81070215 提供任何有用的信息。

微软提供了一个很长的通用值列表,名为 pdf,名称为 MS-ERREF。此列表也不包含请求的错误。

我们可以从描述中看到HRESULT 结构的 ,该值设置了 S 位(这是一个错误),清除了 C 位(Microsoft 定义的,而不是客户定义的) )、N 位清除(不是包装的 NTSTATUS)、Facility 0x107 和 Code 0x215。设施代码 0x107 是 FACILITY_DEPLOYMENT_SERVICES_PXE部署服务 wdspxe.h< 中的函数文档/code> 标头(我根据名称猜想它主要对应于该设施)列出了 WdsPxe.dll 作为相应的库。如果您的系统上有该库,您可以尝试使用FormatMessage,如此答案中所述并将句柄传递给 WdsPxe.dll 而不是该 anwser 中使用的 ntdll.dll

Some of the more common error messages can be looked up via windows built in tools like certutil or net

PS C:\> net helpmsg 5

Access denied

PS C:\> certutil -error '0x80070005'
0x80070005 (WIN32: 5 ERROR_ACCESS_DENIED) -- 2147942405 (-2147024891)
Text of the error message: Access denied

As the question is tagged .net: There is also Marshal.GetExceptionForHR which can be used to translate some HRESULTS into useful .net exceptions.
It can also be called from Powershell:
PS C:\> [System.Runtime.InteropServices.Marshal]::GetExceptionForHR(0x81070215, -1)
Sadly this method also doesn't provide anything useful for the requested value 0x81070215.

A quite long list of common values is available from microsoft as pdf under the name MS-ERREF. This list also doesn't include the requested error.

We can see from the descripton of the HRESULT structure, that the value has the S bit set (it is an error), C bit clear (Microsoft-defined, not customer-defined), N bit clear (not a wrapped NTSTATUS), Facility 0x107 and Code 0x215. Facility code 0x107 is FACILITY_DEPLOYMENT_SERVICES_PXE. The documentation of functions in the Deployment Services wdspxe.h header (which I guess based on the name would be what mostly corresponds to that facility) lists WdsPxe.dll as the corresponding library. If you have that library on your system you could try to use FormatMessage as described in this answer and pass in a handle to WdsPxe.dll instead of ntdll.dll which is used in that anwser.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文