Inno Setup,如何在多个文件中搜索特定字符串?

Inno Setup, How to search specific string in several files?

我想在几个文件中搜索特定的字符串。
例如oem1.inf oem2.inf oem5.inf oem8.inf...
所有目标文件名都具有相同的格式 - oem*.inf
我想在这些文件中搜索特定的子字符串(例如 "1234" in "ABA1234")。
我参考了 Inno setup search for existing file,但它与我的问题有点不同。


我现在可以获取所有路径:

Var
  FilesFound: Integer;
  FindRec: TFindRec;
  Stemp: String;
begin
  FilesFound := 0;
  if FindFirst('C:\Path\oem*.inf', FindRec) then begin
    try
      repeat
        if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then
        begin
          temp := 'C:\Path\' + FindRec.Name;
          MsgBox(temp, mbInformation, MB_OK);
          FilesFound := FilesFound + 1;
        end;
      until not FindNext(FindRec);
    finally
      FindClose(FindRec);
    end;
  end;
  MsgBox(IntToStr(FilesFound) + ' files found in the System directory.',
    mbInformation, MB_OK);
end;

我解决了这个问题。谢谢马丁和肯。

Var
  FindRec: TFindRec;
  I: Integer;
  Tag: String;
  Line: String;
  FileLines: TStringList;
begin
  if FindFirst('C:\PATH\oem*.inf', FindRec) then
    begin
      try
        FileLines := TStringList.Create;
        Tag := 'ABA1234';
        repeat
          if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then
            begin
              FileLines.LoadFromFile('C:\PATH\' + FindRec.Name);
              for I := 0 to FileLines.Count - 1 do
                begin
                  Line := FileLines[I];
                  if (Pos(Tag, Line) > 0) then
                    MsgBox(temp, mbInformation, MB_OK);
                end;
            end;
        until not FindNext(FindRec);
      finally
        FileLines.Free;
        FindClose(FindRec);
      end;
    end;
end;