如何获得英语的boost :: system :: error_code :: message? [英] How to get boost::system::error_code::message in English?

查看:359
本文介绍了如何获得英语的boost :: system :: error_code :: message?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在具有本地化UI的Win7上,error_code::message()返回非英语消息.据我所知(在Boost 1.54中,对于system_error_category),以上函数可归结为以下WinAPI调用:

On Win7 having localized UI, error_code::message() returns a non-English message. As far as I see (in Boost 1.54, for system_error_category), the above function boils down to the following WinAPI call:

DWORD retval = ::FormatMessageA( 
    FORMAT_MESSAGE_ALLOCATE_BUFFER | 
    FORMAT_MESSAGE_FROM_SYSTEM | 
    FORMAT_MESSAGE_IGNORE_INSERTS,
    NULL,
    ev,
    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
    (LPSTR) &lpMsgBuf,
    0,
    NULL 
);

如何获取上述FormatMessage以返回英文消息?我尝试通过std函数和SetThreadLocale设置语言环境-并没有帮助.

How to get the above FormatMessage to return an English message? I tried to set the locale, both with std functions and with SetThreadLocale - it didn't help.

更新:只是澄清一下:本质上,我的问题是如何以编程方式覆盖"

Update: Just a clarification: essentially, my question is how to "override" programmatically the user default language and why setting locale is not enough.

推荐答案

通过在互联网上搜索解决方案,终于找到了

Been searching all over the internet for solution, and finally found this. Basically, you should call SetThreadUILanguage in your main/WinMain.

这篇关于如何获得英语的boost :: system :: error_code :: message?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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