如何获取当前的操作系统语言? [英] How to get current operating system language?

查看:27
本文介绍了如何获取当前的操作系统语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 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;
}

这篇关于如何获取当前的操作系统语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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