是否有办法获取目录中的所有(或仅第一个)子文件夹?我正在尝试将文件安装到具有动态名称的子目录中。它不是 Inno Setup 可用的常量之一。有办法找到这个子目录名吗?
那么,要获取某个文件夹中第一个找到的子文件夹的名称,无论它是哪个,您可以使用以下函数:
[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;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)