Thema: Delphi memo in ini speichern

Einzelnen Beitrag anzeigen

Benutzerbild von SirThornberry
SirThornberry
(Moderator)

Registriert seit: 23. Sep 2003
Ort: Bockwen
12.235 Beiträge
 
Delphi 2006 Professional
 
#22

Re: memo in ini speichern

  Alt 26. Apr 2005, 20:36
und falls man doch die memos in die ini packen will:
Hilfsfunktion
Delphi-Quellcode:
function ConvStrToHex(AStr: String): String;
var LGiveback, LStr: String;
    LCount: Integer;
begin
  setlength(LGiveback, length(AStr) * 2);
  for LCount := 1 to length(AStr) do
  begin
    LStr := IntToHex(Byte(AStr[LCount]), 2);
    move(LStr[1], LGiveback[(LCount - 1) * 2 + 1], 2);
  end;
  result := LGiveback;
end;

function ConvHexToStr(AHex: String): String;
var LGiveback: String;
    LCount: Integer;
begin
  setlength(LGiveback, Trunc(length(AHex) / 2));
  for LCount := 0 to length(LGiveback) - 1 do
    LGiveback[LCount + 1] := Char(StrToInt('$' + AHex[LCount * 2 + 1] + AHex[LCount * 2 + 2]));
  result := LGiveback;
end;
so wird in die Ini-Datei gespeichert
ini.WriteString('Section', 'MemoInhalt', ConvStrToHex(Memo1.Text)); und so wirds wieder ausgelesen
Memo1.Text := ConvHexToStr(ini.ReadString('Section', 'MemoInhalt', ''));
Jens
Mit Source ist es wie mit Kunst - Hauptsache der Künstler versteht's
  Mit Zitat antworten Zitat