In my application, I have to query for System and User Locale and return them as strings (for example, en-US instead of language codes). I can get the LCID for these languages ββfrom the GetSystemDefaultLCID () and GetUserDefaultLCID () functions, but with this I come across the transition from LCID to language strings.
My application should work on Windows XP too, so I cannot use the LCIDToLocaleName () API. The only thing I managed to get the locale name for was using the GetLocaleInfo () API, passing LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT as LCID and LOCALE_SISO639LANGNAME as LCType. My code looks something like this: Query for System Locale
int localeBufferSize = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SISO639LANGNAME, NULL, 0); char *sysLocale = new char[localeBufferSize]; GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SISO639LANGNAME, sysLocale,localeBufferSize);
But the value I get is just the name of the language (only en en-US). To get the full language, I need to call GetLocaleInfo (), passing LOCALE_SISO3166CTRYNAME twice as LCType a second time, and then add two values. Is there a better way to do this?
source share