Inno setup 选择所有文件的源路径
在VisualStudio中编译项目时,我会自动运行模糊处理程序。 模糊处理的.dll文件以相同的文件名保存,但保存在子文件夹中 文件夹结构Inno setup 选择所有文件的源路径,inno-setup,Inno Setup,在VisualStudio中编译项目时,我会自动运行模糊处理程序。 模糊处理的.dll文件以相同的文件名保存,但保存在子文件夹中 文件夹结构 FileA_Secure (subfolder) FileA.dll FileA.dll 问题:如果存在“安全的”FileA.dll,我是否可以确保Inno安装程序从子文件夹FileA\u Secure编译FileA.dll,而不是从主文件夹编译FileA.dll。特别是,请使用: 添加到.iss的末尾,以查看最终脚本是什么样子的: #expr
FileA_Secure (subfolder)
FileA.dll
FileA.dll
问题:如果存在“安全的”FileA.dll
,我是否可以确保Inno安装程序从子文件夹FileA\u Secure
编译FileA.dll
,而不是从主文件夹编译FileA.dll
。特别是,请使用:
添加到.iss的末尾,以查看最终脚本是什么样子的:
#expr SaveToFile(AddBackslash(SourcePath) + "Preprocessed.iss")
如果需要对许多文件执行此操作,可以定义宏:
#define GetDllSource(Name) \
FileExists(Name + "_Secure\" + Name + ".dll") ? \
Name + "_Secure\" + Name + ".dll" : Name + ".dll"
[Files]
Source: {#GetDllSource("MyClass")}; DestDir: "{app}"
Source: {#GetDllSource("MyClass2")}; DestDir: "{app}"
如果要对文件夹及其子文件夹中的所有文件执行此操作,则会变得更加复杂:
#pragma parseroption -p-
; For given DLL, return path to secured DLL, if exists, otherwise return the DLL itself
#define GetDllSource(FileName) \
Local[0] = ExtractFileName(FileName), \
Local[1] = Pos(".", Local[0]), \
Local[2] = Local[1] > 0 ? Copy(Local[0], 1, Local[1] - 1) : Local[0], \
Local[3] = ExtractFilePath(FileName), \
Local[4] = Local[3] + "\\" + Local[2] + "_Secure\\" + Local[0], \
FileExists(Local[4]) ? Local[4] : FileName
; For DLLs, returns [Files] section entry, skip other files
#define FileEntry(Source) \
(ExtractFileExt(Source) != "dll") ? \
"" : "Source: " + GetDllSource(Source) + "; DestDir: {app}\n"
; If the directory entry is folder, call ProcessFolder.
; If it is a file, call FileEntry
#define ProcessFile(Source, FindResult, FindHandle) \
FindResult \
? \
Local[0] = FindGetFileName(FindHandle), \
Local[1] = Source + "\\" + Local[0], \
(Local[0] != "." && Local[0] != ".." \
? (DirExists(Local[1]) ? ProcessFolder(Local[1]) : FileEntry(Local[1])) \
: "") + \
ProcessFile(Source, FindNext(FindHandle), FindHandle) \
: \
""
; If the folder is not _Secure, process its files and subfolders
#define ProcessFolder(Source) \
(Pos("_Secure", ExtractFileName(Source)) > 0) ? \
"" : \
(Local[0] = FindFirst(Source + "\\*", faAnyFile), \
ProcessFile(Source, Local[0], Local[0]))
#pragma parseroption -p+
[Files]
; Process this folder for DLLs and subfolders (can be changed for a real path)
#emit ProcessFolder(".")
我的意思是编译成安装程序,为了更清晰,我修改了我的问题。谢谢,谢谢,但如果我不知道';I don’我不想一个接一个地列出所有文件并进行检查,这样做还是可能的。类似来源**但是对于每个文件X,检查X_Secure\X是否存在,如果存在,请选择该文件。也许你应该向我们展示你的脚本,让我们清楚你实际上在做什么。我可以明天发布它,但我基本上现在就这样做(在编译和删除受保护的子文件夹之前,必须手动替换所有具有模糊版本的文件)。我的希望是自动化这一部分。资料来源:“***”;DestDir:“{app}”标志:recursesubdirs
recursesubdirs
将同时找到模糊版本和未模糊版本,不是吗?你的子文件夹中真的有DLL吗?我明天会试试你的宏。如果可以用*这就是答案。
#pragma parseroption -p-
; For given DLL, return path to secured DLL, if exists, otherwise return the DLL itself
#define GetDllSource(FileName) \
Local[0] = ExtractFileName(FileName), \
Local[1] = Pos(".", Local[0]), \
Local[2] = Local[1] > 0 ? Copy(Local[0], 1, Local[1] - 1) : Local[0], \
Local[3] = ExtractFilePath(FileName), \
Local[4] = Local[3] + "\\" + Local[2] + "_Secure\\" + Local[0], \
FileExists(Local[4]) ? Local[4] : FileName
; For DLLs, returns [Files] section entry, skip other files
#define FileEntry(Source) \
(ExtractFileExt(Source) != "dll") ? \
"" : "Source: " + GetDllSource(Source) + "; DestDir: {app}\n"
; If the directory entry is folder, call ProcessFolder.
; If it is a file, call FileEntry
#define ProcessFile(Source, FindResult, FindHandle) \
FindResult \
? \
Local[0] = FindGetFileName(FindHandle), \
Local[1] = Source + "\\" + Local[0], \
(Local[0] != "." && Local[0] != ".." \
? (DirExists(Local[1]) ? ProcessFolder(Local[1]) : FileEntry(Local[1])) \
: "") + \
ProcessFile(Source, FindNext(FindHandle), FindHandle) \
: \
""
; If the folder is not _Secure, process its files and subfolders
#define ProcessFolder(Source) \
(Pos("_Secure", ExtractFileName(Source)) > 0) ? \
"" : \
(Local[0] = FindFirst(Source + "\\*", faAnyFile), \
ProcessFile(Source, Local[0], Local[0]))
#pragma parseroption -p+
[Files]
; Process this folder for DLLs and subfolders (can be changed for a real path)
#emit ProcessFolder(".")