Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Windows Gebietseinstellungen (https://www.delphipraxis.net/177478-windows-gebietseinstellungen.html)

Satyr 8. Nov 2013 13:29

Windows Gebietseinstellungen
 
Huhu,

gibt es mit Delphi die Möglichkeit auf die Windows Gebietseinstellungen zuzugreifen?
Konkret: Gucken welches Gebiet eingestellt ist, eventuell anderes Gebiet einstellen oder neues Gebiet installieren wenn nicht vorhanden?

Ich schreibe grade einen Launcher für ein älteres Programm aus den USA. Dieses Programm verlangt englische Gebietseinstellungen. Ich möchte das der Launcher das umstellt, programm startet und bei beenden des Programms wieder die Einstellungen zurückstellt. Seht Ihr da eine Chance?

Gruß,
Andreas

Uwe Raabe 8. Nov 2013 13:38

AW: Windows Gebietseinstellungen
 
Soweit ich weiß, werden die Einstellungen per User gesetzt. Du kannst also einen neuen User anlegen, die Einstellungen anpassen und das Programm unter diesem User-Account starten. Es gibt da auch irgendwo sowas wie RunAsUser - musste mal googlen.

Satyr 8. Nov 2013 13:41

AW: Windows Gebietseinstellungen
 
Danke für den Anhaltspunkt, ich fand beim Googeln leider nichts und wusste auch nicht wonach ich genau suchen muss.

TiGü 8. Nov 2013 14:28

AW: Windows Gebietseinstellungen
 
Zitat:

Zitat von Satyr (Beitrag 1235097)
Danke für den Anhaltspunkt, ich fand beim Googeln leider nichts und wusste auch nicht wonach ich genau suchen muss.

Siehe hier:
http://bit.ly/17cM86S

hathor 8. Nov 2013 15:15

AW: Windows Gebietseinstellungen
 
Funktion SetLocaleInfo

Delphi-Quellcode:
function SetLocaleInfo(Locale: LCID; LCType: LCTYPE; lpLCData: PChar): Boolean;

//these are the LCTYPE constants:
LOCALE_ICALENDARTYPE
LOCALE_SDATE
LOCALE_ICURRDIGITS
LOCALE_SDECIMAL
LOCALE_ICURRENCY
LOCALE_SGROUPING
LOCALE_IDIGITS
LOCALE_SLIST
LOCALE_IFIRSTDAYOFWEEK
LOCALE_SLONGDATE
LOCALE_IFIRSTWEEKOFYEAR
LOCALE_SMONDECIMALSEP
LOCALE_ILZERO
LOCALE_SMONGROUPING
LOCALE_IMEASURE
LOCALE_SMONTHOUSANDSEP
LOCALE_INEGCURR
LOCALE_SNEGATIVESIGN
LOCALE_INEGNUMBER
LOCALE_SPOSITIVESIGN
LOCALE_ITIME
LOCALE_SSHORTDATE
LOCALE_S1159
LOCALE_STHOUSAND
LOCALE_S2359
LOCALE_STIME
LOCALE_SCURRENCY
LOCALE_STIMEFORMAT


//Usage:
SetLocaleInfo(GetSystemDefaultLCID, LOCALE_SDATE, '.');

//SetLocalInfo changes your whole computers settings.
To change setting for application only try:

SysUtils.DateSeparator := '.' ;

These are the SysUtils constants:
Delphi-Quellcode:
CurrencyString: string;
CurrencyFormat: Byte;
NegCurrFormat: Byte;
ThousandSeparator: Char;
DecimalSeparator: Char;
CurrencyDecimals: Byte;
DateSeparator: Char;
ShortDateFormat: string;
LongDateFormat: string;
TimeSeparator: Char;
TimeAMString: string;
TimePMString: string;
ShortTimeFormat: string;
LongTimeFormat: string;
ShortMonthNames: array[1..12] of string;
LongMonthNames: array[1..12] of string;
ShortDayNames: array[1..7] of string;
LongDayNames: array[1..7] of string;
SysLocale: TSysLocale;
EraNames: array[1..7] of string;
EraYearOffsets: array[1..7] of Integer;
TwoDigitYearCenturyWindow: Word = 50;
ListSeparator: Char;
oder:

Regional Settings (INTL.CPL)
---------------------------------
Regional Settings Properties (Regional Settings):
rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,0
Regional Settings Properties (Number):
rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,1
Regional Settings Properties (Currency):
rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,2
Regional Settings Properties (Time):
rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,3
Regional Settings Properties (Date):
rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,4

You can call the Region Options Applet:
{This will open the Currency Tab of the Region Options Applet}
Delphi-Quellcode:
ShellExecute(Handle,
PChar('open'),
PChar('rundll32.exe'),
PChar( 'shell32.dll,
Control_RunDLL
intl.cpl,,2'),
nil,
SW_NORMAL);

Satyr 8. Nov 2013 15:59

AW: Windows Gebietseinstellungen
 
Wow, danke! Wenn ich fragen darf, wo hast Du das her?

hathor 8. Nov 2013 16:47

AW: Windows Gebietseinstellungen
 
http://www.delphipages.com/forum/sho...57&postcount=2
-
http://www.delphipages.com/forum/sho...24&postcount=6
-
http://msdn.microsoft.com/en-us/goglobal/bb896001.aspx

Satyr 8. Nov 2013 17:24

AW: Windows Gebietseinstellungen
 
Soweit ich grade gelesen hab, macht das ab Vista Probleme. Ich habe es nun über die Registry gelöst:

Delphi-Quellcode:
var
  reg: TRegistry;
begin
  reg := TRegistry.Create;
 try
  reg.RootKey := HKEY_CURRENT_USER;
  reg.OpenKey('Control Panel\International',true);
  reg.WriteString('Locale', '00000409');
  reg.WriteString('LocaleName', 'en-EN');
 finally
    reg.free;
  end;
Mehr als die 2 Werte brauche ich zum Glück nicht.

hathor 8. Nov 2013 18:07

AW: Windows Gebietseinstellungen
 
Muss das nicht "en-US" sein?

Satyr 8. Nov 2013 18:22

AW: Windows Gebietseinstellungen
 
Dachte ich auch, das zu startende Programm will aber anscheinend nur en-EN.


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:59 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz