雨过天晴 发表于 2013-5-11 09:04:38

DELPHI遍历修改INI文件

procedure SetStartPage_Ex(Apath: string; FileName: string);
var
IniFile: TIniFile;

procedure FindAll(Path: string);
var
    Sr: TSearchRec;
    Fr: Integer;
    Temp_str, Str, ExePath: string;
    I: Integer;
begin
    if rightStr(trim(Path), 1) <> '\' then
      Path := Trim(Path) + '\'
    else
      Path := Trim(Path);

    if not DirectoryExists(Path) then
      Exit;


    Fr := FindFirst(Path + '*.*', faAnyFile, Sr);
    while Fr = 0 do
    begin
      if (Sr.Attr = faDirectory) and (Sr.Name <> '.') and (Sr.Name <> '..') then
      FindAll(Path + '' + sr.Name)
      else if (Sr.Name <> '.') and (Sr.Name <> '..') then
      begin
      if (Sr.Name = FileName) then
      begin
          IniFile := TIniFile.Create(Path + Sr.Name);
          try
            IniFile.WriteString('', '', ' ');
          finally
            IniFile.Free;
          end;
      end;
      end;
      Temp_str := Sr.name;
      FindNext(sr);
      if Temp_str = Sr.Name then
      break;
    end;
    FindClose(Sr);
end;

begin
FindAll(Apath);
end;

45655010 发表于 2013-5-24 22:27:35

什么我不明白啊
页: [1]
查看完整版本: DELPHI遍历修改INI文件