gpt4 book ai didi

inno-setup - 将多个源代码行添加到 Inno 文件部分的函数

转载 作者:行者123 更新时间:2023-12-04 03:16:29 25 4
gpt4 key购买 nike

是否有函数或预处理器指令可用于向 Inno Setup 的文件部分添加多行?例如,我多次出现类似于以下的模式:

[Files]
Source: "{#SrcPath}\Dir1\FileName.*"; DestDir: {#DstPath}\Dir1;
Source: "{#SrcPath}\Dir2\FileName.*"; DestDir: {#DstPath}\Dir2;
Source: "{#SrcPath}\Dir3\FileName\*"; DestDir: {#DstPath}\Dir3\FileName; Flags: recursesubdirs

虽然我可以复制并粘贴每一行,但我想知道我是否可以做这样的事情?

[Files]
AddFiles(FileName)

不幸的是,我无法在文档或网上找到任何说明如何执行此操作的示例。这可能吗?

最佳答案

使用 #define directive 定义预处理器宏(模板)像这样:

#define FileTemplate(str FileName) \
"Source: """ + SrcPath + "\Dir1\" + FileName + ".*""; DestDir: " + DstPath + "\Dir1;" + NewLine + \
"Source: """ + SrcPath + "\Dir2\" + FileName + ".*""; DestDir: " + DstPath + "\Dir2;" + NewLine + \
"Source: """ + SrcPath + "\Dir3\" + FileName + ".*""; DestDir: " + DstPath + "\Dir3; Flags: recursesubdirs"

并使用 #emit directive 展开模板像这样:

#define SrcPath "C:\srcpath"
#define DstPath "{app}"

[Files]
#emit FileTemplate("FileName1")
#emit FileTemplate("FileName2")

如果你得到 preprocessor to dump a preprocessed file ,你会看到代码产生了这个:

[Files]
Source: "C:\srcpath\Dir1\FileName1.*"; DestDir: {app}\Dir1;
Source: "C:\srcpath\Dir2\FileName1.*"; DestDir: {app}\Dir2;
Source: "C:\srcpath\Dir3\FileName1.*"; DestDir: {app}\Dir3; Flags: recursesubdirs
Source: "C:\srcpath\Dir1\FileName2.*"; DestDir: {app}\Dir1;
Source: "C:\srcpath\Dir2\FileName2.*"; DestDir: {app}\Dir2;
Source: "C:\srcpath\Dir3\FileName2.*"; DestDir: {app}\Dir3; Flags: recursesubdirs

换行符 predefined preprocessor variable ,您需要 Inno Setup 6。另请参阅 Emit new line in Inno Setup preprocessor .

关于inno-setup - 将多个源代码行添加到 Inno 文件部分的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40497860/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com