FormatMessage 为另一种语言

FormatMessage to a different language

是否可以将 system error codes 翻译成特定语言?

我只能通过MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US) to FormatMessage。否则,函数调用失败并显示 15100 (资源加载器未能找到 MUI 文件).

系统错误消息存储在哪里?为什么我无法在与系统不同的语言环境中加载消息?

基本上 MUI 代表多语言用户界面。这些是语言包。在 windows 中,默认情况下不会获得它们。相反,他们必须安装

以下link对采购有帮助。

https://support.microsoft.com/en-us/help/14236/language-packs

默认情况下,以上页面显示 windows 10。对于 windows 的其他版本,select 有一个下拉选项。

如果您对上述 link 有困难,请在 google 中搜索 windows 10 或任何其他版本的 MUI 语言包。

语言 ID 使用零,而不是 MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)。然后 FormatMessage 将根据线程的语言 id 选择资源,或者它使用 GetUserDefaultLangID.

FormatMessage 文档:

DWORD WINAPI FormatMessage(
  _In_     DWORD   dwFlags,
  _In_opt_ LPCVOID lpSource,
  _In_     DWORD   dwMessageId,
  _In_     DWORD   dwLanguageId,
  _Out_    LPTSTR  lpBuffer,
  _In_     DWORD   nSize,
  _In_opt_ va_list *Arguments
);

dwLanguageId:

If you pass a specific LANGID in this parameter, FormatMessage will return a message for that LANGID only. If the function cannot find a message for that LANGID, it sets Last-Error to ERROR_RESOURCE_LANG_NOT_FOUND. If you pass in zero, FormatMessage looks for a message for LANGIDs in the following order:

  1. Language neutral
  2. Thread LANGID, based on the thread's locale value
  3. User default LANGID, based on the user's default locale value
  4. System default LANGID, based on the system default locale value
  5. US English