GetUserDefaultUILanguage issues
All,
I have a non-MFC C++ application and I am trying to load a resource dll
based on the default languages. I am running on Windoxs XP-Pro (SP2) and I
used control panel to change my language (for unicode and non-unicode) to
potuguese.
After a reboot, the call to GetUserDefaultUILanguage is still picking up
English.
Here is my code, and all four show ENU as the Locale,
Any ideas as to what is wrong here?
Thanks,
Mark
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define INC_OLE2
#include <stdio.h>
#include <tchar.h>
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
LANGID langid;
int nPrimaryLang = 0;
int nSubLang = 0;
LCID lcid = 0;
LCID lcidAfterConvert;
TCHAR szLangCode[4];
int nResult;
// First try the user's UI language
langid = GetUserDefaultUILanguage();
nPrimaryLang = PRIMARYLANGID(langid);
nSubLang = SUBLANGID(langid);
lcid = MAKELCID(MAKELANGID(nPrimaryLang, nSubLang), SORT_DEFAULT);
lcidAfterConvert = ConvertDefaultLocale(lcid);
nResult = ::GetLocaleInfo(lcidAfterConvert, LOCALE_SABBREVLANGNAME,
szLangCode, 4);
if (nResult == 0)
return NULL;
wprintf_s(L" After GetUserDefaultUI(sublang): lcid=%d, lcidConv=%d,
lang=%s\n",lcid, lcidAfterConvert,szLangCode);
lcid = MAKELCID(MAKELANGID(nPrimaryLang, SUBLANG_NEUTRAL), SORT_DEFAULT);
lcidAfterConvert = ConvertDefaultLocale(lcid);
nResult = ::GetLocaleInfo(lcidAfterConvert, LOCALE_SABBREVLANGNAME,
szLangCode, 4);
if (nResult == 0)
return NULL;
wprintf_s(L" After GetUserDefaultUI(primarylang): lcid=%d, lcidConv=%d,
lang=%s\n",lcid, lcidAfterConvert,szLangCode);
// Then try system's default UI language
langid = GetSystemDefaultUILanguage();
nPrimaryLang = PRIMARYLANGID(langid);
nSubLang = SUBLANGID(langid);
lcid = MAKELCID(MAKELANGID(nPrimaryLang, nSubLang), SORT_DEFAULT);
lcidAfterConvert = ConvertDefaultLocale(lcid);
nResult = ::GetLocaleInfo(lcidAfterConvert, LOCALE_SABBREVLANGNAME,
szLangCode, 4);
if (nResult == 0)
return NULL;
wprintf_s(L" After GetSystemDefaultUI(sublang): lcid=%d, lcidConv=%d,
lang=%s\n",lcid, lcidAfterConvert,szLangCode);
lcid = MAKELCID(MAKELANGID(nPrimaryLang, SUBLANG_NEUTRAL), SORT_DEFAULT);
lcidAfterConvert = ConvertDefaultLocale(lcid);
nResult = ::GetLocaleInfo(lcidAfterConvert, LOCALE_SABBREVLANGNAME,
szLangCode, 4);
if (nResult == 0)
return NULL;
wprintf_s(L" After GetSystemDefaultUI(sublang): lcid=%d, lcidConv=%d,
lang=%s\n",lcid, lcidAfterConvert,szLangCode);
}
date: Tue, 20 May 2008 05:50:04 -0700
author: Mark