Autor Beitrag
Biarchiv
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Do 05.03.09 17:17 
Hallo,

kann man eine ini-Datei auch aus einem String oder Stream statt einer Datei auslesen?
Biarchiv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Mo 09.03.09 17:09 
Hallo,

vielleicht hab ich die Frage etwas falsch formuliert.

Wenn man einen INI Datei in einem TMemoryStream einliest, kann man da auch
mit Delphi eigenen TIniFile zugreifen?
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: Mo 09.03.09 17:24 
TIniFile hat iirc eine Property Strings (oder war es Lines?) vom Typ TStrings. Es sollte also folgendes möglich sein:
ausblenden Delphi-Quelltext
1:
MyIniFile.Strings.LoadFromStream(MyMemoryStream);					


Kann auch sein, dass es diese Property nicht gibt, aber es gibt auf jeden Fall eine Methode, die einen TStrings-Parameter hat (Assign-irgendwas). Zur Not halt eine Stringlist selber erzeugen, die aus dem Stream befüllen und diese dann der Ini zuweisen.

_________________
We are, we were and will not be.
Biarchiv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Fr 20.03.09 16:23 
Hallo,

ich versuchte nun die ini datei bei steam s2 einzulesen.
Leider scheint so keine INI-Datei in den TIniFile zu bekommen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
  s2.Position := 0;
  stl:= TStrings.Create;
  stl.LoadfromStream(s2);
  Ini.SetStrings(stl);


Ini liegt komplett im s2, nur scheint SetStrings(stl); damit nichts anfangen zu können.
stl:= TStringList.Create; geht leider auch nicht.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Fr 20.03.09 18:13 
Moin!
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
  var
    SL: TStringList;
    MI: TMemIniFile;
begin
  SL := TStringList.Create;
  try
    SL.Add('[MySection]');
    SL.Add('MyKey=MyValue');
    MI := TMemIniFile.Create('');
    try
      MI.SetStrings(SL);
      ShowMessage(MI.ReadString('MySection','MyKey','default'));
    finally
      MI.Free;
    end;
  finally
    SL.Free;
  end;
cu
Narses

PS: Ach ja, und nicht TStrings direkt instanziieren, das ist nur eine Hilfsklasse! :idea:

_________________
There are 10 types of people - those who understand binary and those who don´t.