HRESULT翻译为可读消息 [英] Translate HRESULT to a readable message

查看:117
本文介绍了HRESULT翻译为可读消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以提供关于如何编程转换HRESULT( http://en.wikipedia.org/wiki/HRESULT)值,以人类可读的消息?

Can anyone provide some information on how to programmatically translate HRESULT (http://en.wikipedia.org/wiki/HRESULT) values to a human-readable message?

我知道,公用事业ERR.EXE这样做,但我的应用程序需要显示一些有意义的消息,我的用户,而不是一个神秘的0x800A03EC。

I know that the utility ERR.EXE does this, but my app needs to display some meaningful message to my users rather than a cryptic 0x800A03EC.

推荐答案

有没有内置在从该值的HRESULT生成消息的支持。 COM组件需要实现本身,使用的IErrorInfo接口。

There's no built-in support for generating messages from an HRESULT with that value. The COM component needs to implement that itself, using the IErrorInfo interface.

内置于.NET CLR的互操作性支持自动已经这样做,你不应该需要帮助。它会自动抛出,当它看到一个COM接口方法返回一个失败代码适当的异常。消息属性是从的IErrorInfo初始化。如果你什么也得不到体面的消息则COM服务器只是不提供的话。

The CLR interop support built into .NET already does that automatically, you should never need to help. It automatically throws an appropriate exception when it sees a COM interface method return a failure code. The Message property is initialized from IErrorInfo. If you get nothing decent as a message then the COM server just doesn't supply it.

这很可能是为0x800a03ec,它是一个抓斗袋低水平的Excel错误有许多错误的原因。您可以通过谷歌搜索创先争优错误1004发现大量命中为吧。

Which is likely for 0x800a03ec, it is a grab-bag low-level Excel error with many error causes. You can find plenty of hits for it by googling "excel error 1004".

这篇关于HRESULT翻译为可读消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆