Tech Support > Microsoft Windows > Development Resources > Multiple language DLL, FormatMessage and impersonation
Multiple language DLL, FormatMessage and impersonation
Posted by Rade on December 11th, 2004


A couple of questions about localization on Windows 2000/XP/2003 platform...

1) What is the exact algorithm how FormatMessage searches for a message
resource in a multiple language DLL (i.e. DLL with resources in multiple
languages)? It is assumed that FormatMessage is called with
FORMAT_MESSAGE_FROM_HMODULE and with a certain language ID.

MSDN is not very precise, but it covers cases where the supplied language ID
is 0 (i.e. neutral) and where it corresponds to a particular
language/sublanguage pair. What is not clear is how it works if the
sublanguage is neutral, or the language itself is "neutral" (if you pass
LANG_USER_DEFAULT or LANG_SYSTEM_DEFAULT as a language ID).

2) What is the algorithm that other resource API use to find a resource for
a particular language? I think primarily of the functions like LoadResource
(that don't have a language ID supplied as a parameter) and LoadResourceEx
(that have a language ID supplied, but its sublanguage can be neutral, or
the language itself can be neutral). I'd expect that, basically, this
algorithm is used in the "higher level" functions like LoadBitmap or
FormatMessage (see (1)) - am I right?

3) There is also the following article:
http://www.microsoft.com/globaldev/h...ev/muiapp.mspx, where I could
read something like "if the current thread locale matches the user locale,
then the functions like LoadResource will search for *invariant* resources,
rather than the resources in the language that corresponds to this locale".
Sounds strange... does anybody know why is this so, i.e. for which purpose
has this been made to work that way ?

4) If there is any kind of impersonation on a thread, does it affect the
thread's locale ? If yes, does it depend on the particular kind of
impersonation (i.e. does SetThreadToken behave differently than e.g.
CoImpersonateClient) ?

5) Are the answers to the above questions platform-specific ? I mean, are
they the same for all the OS versions mentioned above, and are they
documented or undocumented behavior (prone to changes in future OS
versions)?

I'll appreciate any answers, links to articles, anything, for any of the
above questions.

Regards,
Rade


Posted by Bob Hairgrove on December 11th, 2004


On Sat, 11 Dec 2004 18:08:37 +0000 (UTC), "Rade"
<no.spam@btinternet.com> wrote:

Who cares? The important thing is that it works as documented.

Did you ever look up the value of these constants in the header file?
They are in WinNT.h on my machine:

#define LANG_NEUTRAL 0x00
#define SUBLANG_NEUTRAL 0x00

Same thing, both are 0.

I would expect the functions which do not take a language ID to use
the thread locale or the default system locale. I'm sure that the
Platform SDK documentation has all the details you need.

--
Bob Hairgrove
NoSpamPlease@Home.com


Similar Posts