TINIFILE 最終就是調用系統API:GetPrivateProfileString來做的,必須提供文件名;不過可翠提供你另外一個方法:function TMemIniFile.ReadString(const Section, Ident, Default: string): string; var I: Integer; Strings: TStrings; begin I := FSections.IndexOf(Section); if I >= 0 then begin Strings := TStrings(FSections.Objects[I]); I := Strings.IndexOfName(Ident); if I >= 0 then begin Result := Copy(Strings[I], Length(Ident) + 2, Maxint); Exit; end; end; Result := Default; end; 這是 inifiles 單元裏的。可翠參考下; 通過TLIST來處理。
楼主啊 从MEMO里面 一行行的读 然后在一行行的往ini写吧 ini:=Tinifile.create('MyIniFile'); for i:=0 to Memo1.Lines.Count-1 do begin ini.writestring('Sections','Sections',memo1.Lines[i]); end;
糾正下: memo1.lines.savetoFile('XX.ini');
那就直接對 memo1.lines.savetofile 就行了。
你什麼樣的復制形式?要說清楚啊,:) copy_Data 一樣?? 發送一個信息就把信息COPY到一個地方還是??
Default: string): string;
var
I: Integer;
Strings: TStrings;
begin
I := FSections.IndexOf(Section);
if I >= 0 then
begin
Strings := TStrings(FSections.Objects[I]);
I := Strings.IndexOfName(Ident);
if I >= 0 then
begin
Result := Copy(Strings[I], Length(Ident) + 2, Maxint);
Exit;
end;
end;
Result := Default;
end;
這是 inifiles 單元裏的。可翠參考下; 通過TLIST來處理。
ini.writestring('mysec','myide',memo1.text);
stemp:=ini.readstring('mysec','myide');
...
Ini文件是分行的,而Memo的内容有可能是多行
所以以上代码未测试是否通过,请自己测试
从MEMO里面 一行行的读 然后在一行行的往ini写吧
ini:=Tinifile.create('MyIniFile');
for i:=0 to Memo1.Lines.Count-1 do
begin
ini.writestring('Sections','Sections',memo1.Lines[i]);
end;