ID: Q197572
The information in this article applies to:
- Microsoft Windows NT 4.0
If an executable supports different languages through the use of compiled resources, FindResource() might return a handle to the wrong resource if it is called from a service while there is no interactive user.
FindResource() determines which code page to use based on a cache created when the interactive user logs on to the workstation. An interactive user is any user who logs on by pressing CTRL+ALT+DEL to access the WinLogon dialog box. Because a service can run while there is no interactive user, this cache may not exist. In this event, LoadResource() looks in Locale.nls, the default National Language Support (NLS) file. This file always indicates "English (United States)" as the current language, causing the API to return a handle to the wrong resource.
Use FindResourceEx() and pass the default system language identifier as the wLanguage parameter. This identifier can be retrieved using GetSystemDefaultLangID(). This API should work correctly from within a service, even if there is no interactive user.
This solution requires that you change the system's default locale, not just a user's locale. This is done through the Regional Settings dialog box of the Control Panel, as follows:
1. Select a language other than "English (United States)."
2. Select the "Set as system default locale" check box.
3. Restart the computer for the changes to take place.
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.
Other APIs that retrieve resources such as LoadString() may also fail to retrieve the correct localized resource. In this case, you must use FindResourceEx(), as explained above, and LoadResource() to retrieve the resource. You can then format it as necessary.
Additional query words: kbDSupport
Keywords : kbKernBase kbNTOS400 kbResource kbService
Version : WINNT:4.0
Platform : winnt
Issue type : kbprb
Last Reviewed: December 18, 1998