Ниже показаны две функции, которые помещают и получают значение переменной
(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; |
|