NSIS - 使用偏移量与 !insertmacro 的组合

NSIS - Use offset with combination of !insertmacro

我被迫在我的安装程序中使用这样的标签:

  IfFileExists "$INSTDIR\XX\*.*" XX_Found 0
      !insertmacro UnselectSection ${Section_XX}
  XX_Found:

  IfFileExists "$INSTDIR\YY\*.*" YY_Found 0
      !insertmacro UnselectSection ${Section_YY}
  YY_Found:

因为这些不起作用:

  IfFileExists "$INSTDIR\XX\*.*" +2 0
      !insertmacro UnselectSection ${Section_XX}

  IfFileExists "$INSTDIR\YY\*.*" +2 0
      !insertmacro UnselectSection ${Section_YY}

有什么建议吗?我认为这是因为 !insertmacro 声明,但我在互联网上找不到任何信息或解决方法。

您不能对宏使用相对跳转,因为一个宏可以包含多个指令。 !insertmacro 基本上是在第一个编译阶段将 !macro 的内容粘贴到您的代码中。

我更喜欢使用 LogicLib:

!include LogicLib.nsh
Section
${If} ${FileExists} "$InstDir\file.ext"
  !insertmacro ...
${EndIf}
SectionEnd

也可以使用标签跳过!insertmacro