示例#1
0
static BOOL
pLoadResourceModule(LPCTSTR szFileName)
{
	HINSTANCE hResInst = ::LoadLibrary(szFileName);

	if (NULL == hResInst) {
		pAppInitErrMessage(IDS_APP_INIT_ERROR_RESOURCE_LOAD);
		return FALSE;
	}

	HINSTANCE hPrevResInst = _Module.SetResourceInstance(hResInst);

	return TRUE;
}
示例#2
0
void LoadLocalizedResources()
{
	HMODULE hResources = NULL;

	wchar_t szLang[9];

	// user language
	if(::GetLocaleInfo(LOCALE_CUSTOM_UI_DEFAULT, LOCALE_SISO639LANGNAME2, szLang, 9) > 0)
	{
		wstring dll (L"console_");
		dll += szLang;
		dll += L".dll";
		hResources = ::LoadLibraryEx(dll.c_str(), NULL, LOAD_LIBRARY_AS_DATAFILE);

		Win32Exception ex("LoadLibraryEx", ::GetLastError());
		TRACE(L"LOCALE_CUSTOM_UI_DEFAULT LOCALE_SISO639LANGNAME2=%s dll=%s hResources=%p (%S)\n", szLang, dll.c_str(), hResources, ex.what());
	}

	// default resources are in english
	if(!hResources && ::_wcsicmp(szLang, L"eng") == 0) return;

	// system language
	if(!hResources && ::GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SISO639LANGNAME2, szLang, 9) > 0)
	{
		wstring dll (L"console_");
		dll += szLang;
		dll += L".dll";
		hResources = ::LoadLibraryEx(dll.c_str(), NULL, LOAD_LIBRARY_AS_DATAFILE);

		Win32Exception ex("LoadLibraryEx", ::GetLastError());
		TRACE(L"LOCALE_SYSTEM_DEFAULT LOCALE_SISO639LANGNAME2=%s dll=%s hResources=%p (%S)\n", szLang, dll.c_str(), hResources, ex.what());
	}

	if(hResources)
	{
		_Module.SetResourceInstance(hResources);
	}
}