获取当前系统语言C++
//获取当前系统的语言
static std::string __CheckLocale()
{
//LCID 实际是unsignedlong类型,所以可以通过LCID编码来比较是什么语言
LCID lcid = GetThreadLocale();
wchar_t name[LOCALE_NAME_MAX_LENGTH];
if(LCIDToLocaleName(lcid, name, LOCALE_NAME_MAX_LENGTH, 0) == 0){
// "Get locale name error"
}
std::wstring ws(name);
std::string str(ws.begin(), ws.end());
return str;
}
std::string locale = __CheckLocale();
if (locale.find("zh") != std::string::npos || locale.find("CN") != std::string::npos) {
//中文
}

浙公网安备 33010602011771号