Inno Setup查找子文件夹 [英] Inno Setup find subfolder

查看:190
本文介绍了Inno Setup查找子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

总有没有将所有(或仅第一个)子文件夹放在目录中?我正在尝试将文件安装到具有动态名称的子目录中.它不是Inno Setup可用的常数之一.反正有没有找到该子目录的名称?

Is there anyway to get all (or just the first) subfolder in a directory? I'm trying to install my files into a subdirectory that has a dynamic name. It is not one of the constants available with Inno Setup. Is there anyway to find this subdirectory name?

推荐答案

好,要获取某个文件夹的第一个找到的子文件夹的名称,无论它是哪个文件夹,都可以使用以下功能:

Well, to get name of a first found subfolder of a certain folder, no matter which one it is, you may use the following function:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[Code]
function TryGetFirstSubfolder(const Path: string; out Folder: string): Boolean;
var
  S: string;
  FindRec: TFindRec;
begin
  Result := False;
  if FindFirst(ExpandConstant(AddBackslash(Path) + '*'), FindRec) then
  try
    repeat
      if (FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0) and
        (FindRec.Name <> '.') and (FindRec.Name <> '..') then
      begin
        Result := True;
        Folder := AddBackslash(Path) + FindRec.Name;
        Exit;
      end;
    until
      not FindNext(FindRec);
  finally
    FindClose(FindRec);
  end;
end;

procedure InitializeWizard;
var
  S: string;
begin  
  if TryGetFirstSubfolder('C:\Folder', S) then
    MsgBox('The first found subfolder is: ' + S, mbInformation, MB_OK);
end;

这篇关于Inno Setup查找子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆