Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Tue, 20 May 2008 05:50:04 -0700,    group: microsoft.public.win32.programmer.directx.misc        back       


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

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us