Как сохранить/получить строку из INI-файлаНиже показаны две функции, которые помещают и получают значение переменной (StringName) в ini-секции (IniSection) ini-файла (TheIniFile)}
Function IniGetStringValue(
TheIniFile : String;
IniSection : String;
StringName : String;
DefaultString : String): String;
Var
TheIni : TIniFile;
Begin
TheIni := TIniFile.Create(Self);
Try
Result :=
TheIni.ReadString(
IniSection,
StringName,
DefaultString);
If Result = '' Then
Result := DefaultString;
Finally
TheIni.Free;
End;
End;
Function IniSetStringValue(
TheIniFile : String;
IniSection : String;
StringName : String;
StringValue : String): Boolean;
Var
TheIni : TIniFile;
Begin
TheIni := TIniFile.Create(Self);
Try
Try
TheIni.WriteString(
IniSection,
StringName,
StringValue);
Result := True;
Except
Result := False;
End;
Finally
TheIni.Free;
End;
End;
|
|
|
|
|