SetThreadLocale Not Working
I'm trying to change the ThreadLocaleID to (force) the exe to run on English UK (2057) Regional Settings, but SetThreadLocale (2057) has no effect?
I simply need to make sure that Decimal points are returned as "." instead of ",".
I've ready many threads / posts without much result other than manually changing the Decimal.
Code:
Ret = GetLocaleInfo(LCID, LOCALE_SDECIMAL, Data, DataLen)
Yes, this works, but this does a global system change rather than a temporary change for the app.
I also haven't found a way to simply change the whole Region>FORMAT to English UK somehow?
Any ideas...
Re: SetThreadLocale Not Working
Re: SetThreadLocale Not Working
Hi dilettante,
As much as that thread has a solution, it's rather a function than I'll need to pass for every call, rather than a Global solution.
If I was designing from scratch, then yes, I'd be using that method, but as this is an existing BIG project, it's a no go zone to try and find every single call to fix.
Hence why simply changing the Regional Format is a single global solution that I'm after.
Re: SetThreadLocale Not Working
I've tried this in the past, and I've never gotten it to work or seen a solution that works.
Re: SetThreadLocale Not Working
Well as far as I can tell CStr(), Format$(), CDbl(), CSng(), CDec(), and CCur() always use the user's current locale. They ignore the thread's locale.
See VarFormat function for example, which underlies Format$():
Quote:
Remarks
This function uses the user's default locale while calling VarTokenizeFormatString and VarFormatFromTokens.
For that matter using UK English doesn't make a lot of sense. It has a few quaint quirks. You probably want LCID_INVARIANT = 127 instead. That is the one you use for universal number formatting and parsing.
As a quick and dirty alternative you might consider using Str$() and Val(). These are obsolete and slow and sloppy but they always use LCID_INVARIANT formatting.
Re: SetThreadLocale Not Working
Hi ,
may sound funny but use Val that uses . instead of ,
nomatter which Regional Settings
regards
Chris
Re: SetThreadLocale Not Working
Not funny at all.
The old functions from old Basic use the Invariant Locale formatting because they use U.S. English formatting which is the same thing, i.e. Earth Standard.
Just as UTC time is the same as GMT time. Accidents of history.