[fpc-devel] GetLocaleInfo strange result in Windows 7

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Fri Jan 21 14:10:52 CET 2011



On Fri, 21 Jan 2011, LacaK wrote:

> Hi *,
> consider following sample program:
>
> var
> b: array[0..255] of char; begin
> if getlocaleinfoa(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, b, sizeof(b)) > 0 
> then
>     writeln('LOCALE_USER_DEFAULT:',b);
> if getlocaleinfoa(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, b, sizeof(b)) > 
> 0 then
>     writeln('LOCALE_SYSTEM_DEFAULT:',b);
> if getlocaleinfoa(GetThreadLocale, LOCALE_SSHORTDATE, b, sizeof(b)) > 0 then
>     writeln('GetThreadLocale:',b);  end;
>
> In Windows XP/Vista returns:
> LOCALE_USER_DEFAULT:d. M. yyyy
> LOCALE_SYSTEM_DEFAULT:d. M. yyyy
> GetThreadLocale:d. M. yyyy                             <--IS OK
>
> In Windows 7 returns:
> LOCALE_USER_DEFAULT:d. M. yyyy
> LOCALE_SYSTEM_DEFAULT:d. M. yyyy
> GetThreadLocale:M/d/yyyy                                 <--HERE IS PROBLEM
>
> So because calls to getlocaleinfo with argument GetThreadLocale is used to 
> initialize DefaultFormatSettings, in Windows 7 are some locale specific 
> global variables (ShortDateFormat, DateSeparator etc.) initialized 
> incorrectly.
> Has anybody else this experience ?

Yes, in Delphi 7.

>
> Now I find:
> http://qc.embarcadero.com/wc/qcmain.aspx?d=80189
> http://stackoverflow.com/questions/1767946/getthreadlocale-returns-different-value-than-getuserdefaultlcid
>
> So can you fix this problem somewhere in initialization process ?

Please file a bugreport, citing the stackoverflow answer.

Michael.



More information about the fpc-devel mailing list