Article View: borland.public.cppbuilder.nativeapi
Article #7508Re: LoadString fails in Win2k / Win XP
From: Thorsten Kettner
Date: Wed, 26 Jan 2005 15:22
Date: Wed, 26 Jan 2005 15:22
62 lines
3260 bytes
3260 bytes
Thank you Dennis. The link doesn't work, but I understand what happens. LoadString ignores User language setting and uses OS language instead. Which means on a computer in a German company only German strings are shown, so colleagues from abraod coming here are not able to use the program on our computers, because even if we set language to English it has no effect. You are right, this is silly. It makes LoadString worthless for exes and dlls holding multiple language resources. We will do what you suggest and write our own LoadString function. Thanks. Thorsten. ------------------------------------------------------------- "Dennis Jones" <nospam@bogus.com> wrote: > >"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:
<41f7b5c5$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.zanker.org!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<41f5ffbc$1@newsgroups.borland.com> <41f68aa7@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: "Thorsten Kettner" <QUESTIONBYthorsten.kettner@otto.de> Sender: "Thorsten Kettner" <QUESTIONBYthorsten.kettner@otto.de> Reply-To: "Thorsten Kettner" <QUESTIONBYthorsten.kettner@otto.de> Subject: Re: LoadString fails in Win2k / Win XP Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 80.85.196.92 References: <41f5ffbc$1@newsgroups.borland.com> <41f68aa7@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <41f7b5c5$1@newsgroups.borland.com> Date: 26 Jan 2005 07:22:45 -0800 X-Trace: newsgroups.borland.com 1106752965 207.105.83.66 (26 Jan 2005 07:22:45 -0800) Lines: 63 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.zanker.org!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail