如何将 Win32 异常代码转换为字符串? [英] How do I convert a Win32 exception code to a string?

查看:18
本文介绍了如何将 Win32 异常代码转换为字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不情愿地不得不再次处理 Win32 结构化异常.我正在尝试生成一个描述异常的字符串.大部分都很简单,但我坚持一些基本的东西:如何转换异常代码(GetExceptionCode() 的结果,或ExceptionCode 的成员EXCEPTION_RECORD) 转换为描述异常的字符串?

I'm reluctantly having to deal with Win32 structured exceptions again. I'm trying to generate a string describing an exception. Most of it is straightforward, but I'm stuck on something basic: how can I convert an exception code (the result of GetExceptionCode(), or the ExceptionCode member of an EXCEPTION_RECORD) into a string describing the exception?

我正在寻找可以将例如 0xC0000005 转换为访问冲突"的内容.只是调用 FormatMessage() 吗?

I'm looking for something that will convert eg 0xC0000005 to "Access Violation". Is it just a call to FormatMessage()?

推荐答案

是的.这是一个NTSTATUS,所以使用FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_FROM_HMODULE,并从LoadLibrary("NTDLL.DLL")传递HMODULE>

Yes. It's a NTSTATUS, so use FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_FROM_HMODULE, and pass the HMODULE from LoadLibrary("NTDLL.DLL")

来源:KB259693(已存档)

这篇关于如何将 Win32 异常代码转换为字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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