如何从像systeminfo.exe显示的Locale字符串中检索“Human Readable”字符串?

时间:2012-11-27 06:45:23

标签: c++ c winapi locale native

System Locale:             en-us;English (United States)
Input Locale:              en-us;English (United States)

运行systeminfo.exe时,有用信息包括以上两行。 Windows API或C运行时函数是否提供字符串英语(美国)

1 个答案:

答案 0 :(得分:0)

它可以用GetLocaleInfo。我想,LCTYPE是LOCALE_SENGLANGUAGE / LOCALE_SENGCOUNTRY。

#include <windows.h>
#include <stdio.h>

int
main() {
  char language[256] = {0}, country[256] = {0};
  GetLocaleInfo(
    GetUserDefaultLCID(),
    LOCALE_SENGLANGUAGE,
    language,
    sizeof(language));
  GetLocaleInfo(
    GetUserDefaultLCID(),
    LOCALE_SENGCOUNTRY,
    country,
    sizeof(country));
  printf("%s (%s)\n", language, country);
}
// I got "Japanese (Japan)"