HOWTO: Load the Right Resource Copy on both Windows NTand Windows 95 and Windows 98ID: Q221209
|
For an application with multiple resource copies, it is expected that a different resource copy will be loaded on both Windows NT and Windows 95 or Windows 98 after it is changed in the regional settings of the Control Panel. For example, in an EXE with both English_US and French_France resource copies, by changing the regional setting from English_US to French_France you expect to see French_France resource but this is only true on Windows NT. On English Windows 95 or 98, the English_US resource copy will always be loaded independent of regional settings. Similarly, on French Windows 95 or 98, French_France resource copy will always be loaded.
This behavior is by design on both Windows 95 and Windows 98. The way the system loads resources on Windows 95 and Windows 98 is different from that on Windows NT. On Windows 95 and Windows 98 there is a registry key HKEY_USERS\.Default\Control Panel\Desktop\ResourceLocale\(default) which is set to the langauge ID of the operating system (0x0409 for English_US and 0x040c for French_France). Whenever there is a resource copy whose language ID matches this registry key value, it will be loaded from the resource copies.
On Windows 95 and Windows 98, if you want to load any specific resource whose language ID is not related to a locale or system locale, it is better to use one resource-only DLL for each language. However, if you just want to load the language resource copy according to the regional settings in the Control Panel, then use the following workaround while keeping a multilingual .rc file:
LANGID langid = GetUserDefaultLangID();
LPTSTR id = MAKEINTRESOURCE(IDR_MAINFRAME); //the resource id of the menu to be loaded
HRSRC hrsrc = FindResourceEx(hinst,RT_MENU,id,langid);
HGLOBAL hglb = LoadResource(hinst,hrsrc);
LPVOID lpsz = LockResource(hglb);
cs.hMenu = LoadMenuIndirect(lpsz);
Additional query words:
Keywords : kbNTOS400 kbWinOS2000 kbResource kbSDKPlatform kbVC500 kbVC600 kbWinOS95 kbWinOS98
Version : WINDOWS:6.0,95,97,98; winnt:4.0,5.0
Platform : WINDOWS winnt
Issue type : kbhowto
Last Reviewed: June 8, 1999