简体   繁体   English

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

[英]NSIS - Use offset with combination of !insertmacro

I was forced to use labels in my installer like this: 我被迫在安装程序中使用标签,如下所示:

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

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

because these does not work: 因为这些不起作用:

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

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

Any proposal why? 有什么建议吗? I think its because of !insertmacro statement but i could not find any information or workaround on the internet. 我认为这是因为!insertmacro语句引起的,但我在互联网上找不到任何信息或解决方法。

You cannot use relative jumps on macros because a macro can contain more than one instruction. 您不能在宏上使用相对跳转,因为一个宏可以包含多个指令。 !insertmacro basically pastes the content of the !macro into your code during the first compiler phase. !insertmacro基本上在第一个编译器阶段将!macro的内容粘贴到您的代码中。

I prefer using the LogicLib: 我更喜欢使用LogicLib:

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

You can also use labels to jump over !insertmacro . 您也可以使用标签跳过!insertmacro

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM