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
);
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.