多语言的设置 的学习



近来学习”多语言的设置”时,查看MSDN的SetThreadLocaleFunction网页时有如此:

Windows Vista and later:Do notuseSetThreadLocaleto select a user interface language. The resource loader selects the resourcethat is defined in the .rc file with a LANGUAGE statement, or the applicationcan useFindResourceEx. Additionally, theapplication can useSetThreadUILanguage.

Windows 2000,Windows XP: Do not use SetThreadLocaleto select a user interface language. To select the resource that is defined inthe .rc file with a LANGUAGE statement, the application must use theFindResourceEx function.

 

具体的代码实现如下|

LCID GetDefaultLCID()
{
	LCID lcid = GetUserDefaultLCID();

	HKEY hKey;
	if(gFaxName.IsEmpty())
	{
		if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, SWPACKET_VERSION, 0, KEY_QUERY_VALUE, &hKey))
		{
			return lcid;
		}
	}
	else
	{
		CString regkey;
		regkey=COMMONREGKEY;
		regkey.Append(_T("\\"));
		regkey.Append(gFaxName);
		regkey.Append(_T("\\Version"));
		if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, regkey, 0, KEY_QUERY_VALUE, &hKey))
		{
			return lcid;
		}
	}

	DWORD dwType;
	DWORD dwcbData;
	DWORD dwVal;

	dwcbData = sizeof(dwVal);

	LSTATUS lStatus = RegQueryValueEx(hKey, _T("language"), NULL, &dwType, (LPBYTE)&dwVal, &dwcbData);
	if (ERROR_SUCCESS == lStatus)
	{
		lcid = (LCID)dwVal;
	}

	RegCloseKey(hKey);

	return lcid;
}

void UpdateLanguage()
{
    OSVERSIONINFO osvi;
    BOOL bIsVistaOrLater;

	ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);

	GetVersionEx(&osvi);

	bIsVistaOrLater = (osvi.dwMajorVersion > 5);

	LCID lcid = GetDefaultLCID();

	//SetThreadUILanguage(MAKELANGID(LANG_DANISH, SUBLANG_DANISH_DENMARK));
	// English:1033, French:1036, Italian: 1040, German: 1031
	// Spanish: 1034, Danish: 1030, Dutch: 1043, Norwegian: 1044
	// Swedish: 1053
	if (bIsVistaOrLater)
	{
		SetThreadUILanguage(LANGIDFROMLCID(lcid));
	}
	else
	{
		SetThreadLocale(lcid);
	}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值