Microsoft KB Archive/221209

= HOWTO: Load the Right Resource Copy on both Windows NTand Windows 95 and Windows 98 =

Article ID: 221209

Article Last Modified on 1/24/2007

-

APPLIES TO


 * Microsoft Windows 98 Standard Edition
 * Microsoft Windows 95
 * Microsoft Windows NT Server 4.0 Standard Edition
 * Microsoft Windows NT Workstation 4.0 Developer Edition
 * Microsoft Visual C++ 5.0 Professional Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q221209



SUMMARY
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.



MORE INFORMATION
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:


 * Change the sublanguage of the language ID of each resource copy to SUBLANG_NEUTRAL.
 * Use FindResourceEx to find the correct copy of the menu and use LoadMenuIndirect to load it, and update the menu in SMMSetup.dll.

Steps to Reproduce Behavior
 Open an .rc file and choose Text in the Open as field of the active dialogue box. Find the Language statement in the .rc file and replace the sublanguage with SUB_NEUTRAL (or 0x0). Save the .rc file.  Open the .cpp file which handles the menu (MainFrm.cpp for the case of mainframe menu), and add the following code in PreCreatWindow: 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);  Rebuild the project.

Keywords: kbdsxglobal2003swept kbhowto kbresource KB221209

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.