Autor Beitrag
muppet max
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 25.03.06 16:05 
Wie kann ich mit INI Dateien die Sprache Ändern?

Dieser Code erzeugt eine Fehlermeldung

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.FormCreate(Sender: TObject);
var
  Ini: TIniFile;
begin

    Ini:=TIniFile.Create('C:\Test.ini');
    if Ini.ReadString('test',
                     'Sprache','English')
then
                      Sprache:=English
end;


Ich hab schon im Delphi Forum gesucht und nichts gefunden :cry:

Ich bitte um Hilfe :?:
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 25.03.06 16:09 
Ini.readString liefert keinen Bool zurück, sondern einen String.
Das sollte funktionieren:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.FormCreate(Sender: TObject);   
var   
  Ini: TIniFile;   
begin   
    Ini := TIniFile.Create('C:\Test.ini');   
    Sprache := Ini.ReadString('test','Sprache','English');

    Ini.free;
end;

_________________
We are, we were and will not be.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Sa 25.03.06 16:09 
muppet max
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 25.03.06 16:27 
Ich habe es versucht, aber diese anweißung erzeugt eine Zugriffsverletzung auf kernel32.dll

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.FormCreate(Sender: TObject);   
var   
  Ini: TIniFile;
  Sprache: String;
begin   
    Ini := TIniFile.Create('C:\Test.ini');   
    Sprache := Ini.ReadString('test','Sprache','');
    Ini.free;
    if Sprache = Ini.ReadString('test','Sprache','English')
    then
    ShowMessage('Hallo')
end;


wie könnte das machen?

Danke für die Hilfe
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 25.03.06 16:29 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.FormCreate(Sender: TObject);   
var   
  Ini: TIniFile;
  Sprache: String;
begin   
    Ini := TIniFile.Create('C:\Test.ini');   
    Sprache := Ini.ReadString('test','Sprache','');
    Ini.free;

    if Sprache = 'English' then
      ShowMessage('Hallo')
end;

_________________
We are, we were and will not be.
muppet max
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 25.03.06 16:33 
Titel: Danke
Danke, das Problem ist gelöst :D :lol: