杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2372|回复: 0

Inno Setup 在目录或子文件夹中查找文件

[复制链接]
发表于 2017-3-6 18:34:28 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

您需要 登录 才可以下载或查看,没有账号?立即注册

x


  1. [Setup]
  2. AppName=我的程序
  3. AppVerName=我的程序 版本 1.5
  4. DefaultDirName={pf}\我的程序
  5. DefaultGroupName=我的程序

  6. [Code]
  7. var sDir: string;
  8.   filefounded: boolean;

  9. procedure RecursiveFileSearch(BeginDir, FilePattern: string);
  10. var FR: TFindRec;
  11. begin
  12.   if FindFirst(BeginDir+'\'+FilePattern, FR) then begin  //搜索目录中的文件
  13.       try
  14.       repeat
  15.         if FR.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then
  16.           begin
  17.           sDir:= BeginDir;
  18.           filefounded:= true;
  19.           Exit;
  20.           end
  21.       until not FindNext(FR);
  22.       finally
  23.         FindClose(FR);
  24.     end;
  25.   end;
  26.   
  27.   if FindFirst(BeginDir+'\*', FR) then begin   //搜索目录中的子目录
  28.     try
  29.       repeat
  30.         if (FR.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0) and (FR.Name<>'.') and (FR.Name<>'..') then
  31.             RecursiveFileSearch(BeginDir+'\'+FR.Name, FilePattern);      //在子目录中继续搜索文件
  32.       until not FindNext(FR);
  33.     finally
  34.       FindClose(FR);
  35.     end;
  36.   end;
  37. end;

  38. procedure InitializeWizard ();
  39. begin
  40. sDir:= '';
  41. filefounded:= false;
  42. RecursiveFileSearch('E:\', '自定义窗口.iss');    // 开始搜寻的位置以及要搜寻的文件名
  43. if filefounded then
  44.   if MsgBox('找到文件在: ' + sDir + #10#13 + '你想要删除该文件夹吗?', mbConfirmation, MB_YESNO) = IDYES then
  45.     DelTree(sDir, true, true, true);
  46. end;
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-5-19 20:25 , Processed in 0.106969 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表