如何获取当前的操作系统语言?
我是 mfc 的新手,我对如何获取当前操作系统语言感到震惊(例如:如果是英文操作系统,我必须获取它,因为英语和语言环境可能不同.对于英语操作系统语言环境可以是日语反之亦然).
I am newbie to mfc, and I got struck over how to get the current operating system language (Ex: If it is English operating system I must get it as English and locale can be different. For English OS locale can be Japanese vice versa).
当前语言环境我通过 GetSystemDefaultLangID
获得它,我唯一剩下的就是我需要获得当前的操作系统语言.
Current locale I am getting it through GetSystemDefaultLangID
and the only thing I was left with is I need to get the current operating system language.
谁能帮我解决这个问题.
Can anyone kindly help me to resolve this issue.
推荐答案
也许你需要GetUserDefaultUILanguage
.系统设置和用户设置可能不一样.
Perhaps you need GetUserDefaultUILanguage
. The system's settings and user settings may not be the same.
用户界面语言管理
int wmain()
{
wcout << "GetUserDefaultUILanguage: " << GetUserDefaultUILanguage() << "
";
wcout << "GetSystemDefaultUILanguage: " << GetSystemDefaultUILanguage() << "
";
wcout << "
";
wcout << "GetUserDefaultLangID: " << GetUserDefaultLangID() << "
";
wcout << "GetSystemDefaultLangID: " << GetSystemDefaultLangID() << "
";
wcout << "
";
wcout << "GetUserDefaultLCID: " << GetUserDefaultLCID() << "
";
wcout << "GetSystemDefaultLCID: " << GetSystemDefaultLCID() << "
";
wcout << "
";
wchar_t buf[100];
LCID lcid = GetUserDefaultLCID();
cout << "GetUserDefaultLCID: " << "
";
if (GetLocaleInfo(lcid, LOCALE_ILANGUAGE, buf, 100)) wcout << buf << "
";
if (GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, buf, 100)) wcout << buf << "
";
if (GetLocaleInfo(lcid, LOCALE_SISO639LANGNAME, buf, 100)) wcout << buf << "
";
return 0;
}
相关文章