NSIS-setup.ini文件中的读取和执行部分提及

问题描述 投票:0回答:1

我是新来使用NSIS来创建安装程序的人。我需要如下帮助

setup.ini的结构: ; section titles [setup] sec0=my first section sec1=my second section sec2=my third section

Nsis脚本结构 ;Sections Section 'sec0' ; ... SectionEnd Section 'sec1' ; ... SectionEnd Section 'sec2' ; ... SectionEnd 我在这里查看的是,如果我没有在setup.ini文件中包括“ sec1 =我的第二部分”,那么Installer应该跳过此步骤而不安装。意味着安装程序应首先阅读setup.ini,然后仅安装其中提到的部分。请让我知道,我该如何实现。

installer nsis
1个回答
0
投票
!include Sections.nsh
!include LogicLib.nsh

Section 'sec0'
SectionEnd

Section 'sec1' SID_1
SectionEnd

Section 'sec2'
SectionEnd

!macro SetSectionFromAnswer inient sid
ReadIniStr $0 "$exedir\Setup.ini" "setup" "${inient}"
${If} $0 == "" 
 !insertmacro UnselectSection ${sid} 
${EndIf} 
!macroend

Function .onInit
!insertmacro SetSectionFromAnswer "sid1"  ${SID_1}
FunctionEnd

[使用这样的答案文件时,建议您不要检查条目是否不存在,而应检查它是否为!= "0"。这样,即使.ini不存在,安装程序也将正常运行。

© www.soinside.com 2019 - 2024. All rights reserved.