【问题标题】:NSIS call function once time if at least one section is selected如果至少选择了一个部分,则 NSIS 调用一次函数
【发布时间】:2013-06-13 17:51:26
【问题描述】:

我有一个功能

Function installDll

...
EndFunction

我有一些部分:

  • 一个
  • b
  • c
  • d
  • e
  • f

如果至少选择了 { a, b, c, d} 部分之一,我想调用函数 installDll 一次。

【问题讨论】:

  • 您需要在选择组件时调用您的函数,还是仅在安装第一个选定组件期间调用?
  • 仅在安装第一个选定组件的过程中

标签: function nsis


【解决方案1】:

您可以从每个相关部分调用您的函数,并使用变量作为标志来了解该函数是否已被调用:

!include "LogicLib.nsh"    ;used for ${if} constructs

Section "A"
    Call installDll
SectionEnd

Section "B"
    Call installDll
SectionEnd

Section "C"
    Call installDll
SectionEnd

Section "D"
    Call installDll
SectionEnd

Section "Other"
    ;... do not call the function
SectionEnd

Var instFlag
Function installDll

    ${ifThen} $instFlag = 1 ${|} goto skip ${|}
    StrCpy $instFlag 1

    ;... the rest of your function

    ;the following label is the last statement of the function
    skip:
EndFunction

【讨论】:

  • 谢谢!另一个问题:我有一个未命名的部分。此部分是在其他部分之前还是之后执行?
  • @user2084608:这些部分按照它们在 nsis 脚本中出现的顺序执行,如果它们被选中。您可以使用${debug} 'message' 在该部分中检查,并使用DebugView 之类的工具来收听调试消息
  • 如果你没有使用nsdialogs.nsh,你可以用!define DEBUG System::Call kernel32::OutputDebugString(ts)定义${debug}宏
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-15
  • 1970-01-01
  • 1970-01-01
  • 2014-12-23
  • 1970-01-01
  • 2011-07-05
相关资源
最近更新 更多