🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #7504

Re: LoadString fails in Win2k / Win XP

#7504
From: Dennis Jones
Date: Tue, 25 Jan 2005 18:08
44 lines
2295 bytes
"Thorsten Kettner" <QUESTIONBYthorsten.kettner@otto.de> wrote in message
news:41f5ffbc$1@newsgroups.borland.com...
>
> Hi all,
> my program is being used in UK and in Germany. To get a string
> in the appropriate language, I use
>
>   MyAnsiString.LoadString(HInstance, MYRESID);
>
> This works fine in Win NT and Win 98, but in Win XP and Win 2000
> I always get the German string.
>
> My resource file contains two string tables:
>
> STRINGTABLE DISCARDABLE
> LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
> BEGIN
> MYRESID "Some text in English."
> END
>
> STRINGTABLE DISCARDABLE
> LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL
> BEGIN
> MYRESID "Ein Text in deutsch."
> END
>
> I checked GetUserDefaultLangID() and GetUserDefaultLCID(), and
> both work correctly under 98, NT, 2000 and XP. (German/Germany
> is code 1031, English/Great Britain is 2057).
>
> Any idea what's going wrong?

Windows 2K and XP have changed the way they load resources.  See
http://support.microsoft.com/default.aspx?scid=kb;en-us;300680.  In a
nutshell, instead of using the thread locale, LoadString always uses the
default language ID of the OS.  It's kind of silly in my estimation, but
that's what they did.

You could write your own version of LoadString() that would take an argument
specifying the language, and then load the string using the FindResourceEx,
LoadResource, and LockResource API functions.

- Dennis
Technical Details
Message-ID: <41f68aa7@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news.zanker.org!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <41f5ffbc$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,26d4ad2d5662e41d
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Dennis Jones" <nospam@bogus.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <41f5ffbc$1@newsgroups.borland.com>
Subject: Re: LoadString fails in Win2k / Win XP
Date: Tue, 25 Jan 2005 10:08:33 -0800
Lines: 46
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 204.200.27.7
Message-ID: <41f68aa7@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1106676391 204.200.27.7 (25 Jan 2005 10:06:31 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news.zanker.org!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail