Autor Beitrag
FSS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 83

Win 7 Professional 64Bit
Delphi 7 PE, Delphi 2005 PE, Turbo Delphi Explorer 2006
BeitragVerfasst: Fr 25.08.06 13:44 
Hallo,

ich möchte aus einer Ini-Datei einen String auslesen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure Tnutzerverwaltung.Button1Click(Sender: TObject);
var
  Ini :TIniFile;
begin
  Ini := TIniFile.Create(ExtractFileDrive(ParamStr(0)) + '\WINDOWS\lavuserin.ini');
  try
  Label_user.Caption := Ini.ReadString(Form_password.user,'user','');
  Label_name.Caption := Ini.ReadString(Form_password.user,'name','');
  Ini.Free;
  except
  MessageDlg('Es konnte keine Verbindung zur Userdatenbank hergestellt werden', mtError, [mbOK], 0);
  end;

end;


Soweit klappt das auch alles, wenn der Eintrag im Ini-File aber nicht existiert, soll die MessageDLG erscheinen, das tut Sie aber nicht. Das Label bleibt einach leer. Weiß jemand woran das liegt?
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Fr 25.08.06 13:50 
Zitat:
Weiß jemand woran das liegt?

Jep.
Ein Inifile macht keine Exception, wenn etwas nicht existiert. Du kannst nur prüfen, ob der Default-Wert(Der letzte Parameter bei den Read*-Funktionen) zurückgegeben wird und darauf reagieren.

//Martok

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
FSS Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 83

Win 7 Professional 64Bit
Delphi 7 PE, Delphi 2005 PE, Turbo Delphi Explorer 2006
BeitragVerfasst: Fr 25.08.06 14:01 
Ok, danke für deine schnelle Hilfe! Habs hinbekommen.