如何获得英语的boost :: system :: error_code :: message? [英] How to get boost::system::error_code::message in English?
问题描述
在具有本地化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屋!