有没有办法使用win API获取HRESULT值的字符串表示? [英] Is there a way to get the string representation of HRESULT value using win API?

查看:964
本文介绍了有没有办法使用win API获取HRESULT值的字符串表示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在win API中有一个函数可以用来提取HRESULT值的字符串表示形式吗?

Is there a function in win API which can be used to extract the string representation of HRESULT value?

问题是并不是所有的返回值都记录在MSDN ,例如 ExecuteInDefaultAppDomain()函数未记录返回0x80070002 - 系统找不到文件指定。,但是,它!因此,我想知道是否有一个常用的函数。

The problem is that not all return values are documented in MSDN, for example ExecuteInDefaultAppDomain() function is not documented to return "0x80070002 - The system cannot find the file specified.", however, it does! Therefore, I was wondering whether there is a function to be used in common case.

推荐答案

你可以使用 _ com_error

_com_error err(hr);
LPCTSTR errMsg = err.ErrorMessage();

如果您不想使用 _com_error 无论什么原因,你仍然可以看看它的来源,看看它是如何做。

If you don't want to use _com_error for whatever reason, you can still take a look at its source, and see how it's done.

这篇关于有没有办法使用win API获取HRESULT值的字符串表示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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