我发现很难在nsis的组件页面中更改选择。 要求是在安装过程中获得许可协议页面,如果用户同意他/她将点击我同意,用户点击我同意后,我想知道哪个操作系统 正在安装安装程序,它可以在Windows Embedded OS或WinXp / Win7上安装。 因此,如果是Windows Embedded OS,我想更改安装包,如果它不是Windows Embedded OS,那么安装包将会有所不同。
我在我的项目中使用的是MUI ver1而不是MUI2。 请告诉我如何实现这一目标。
答案 0 :(得分:1)
要测试运行安装程序的操作系统,您可以使用Winver.nsh
定义的宏和LogicLib.nsh
提供的宏来进行优雅的测试
;Dont't forget to include
!include "LogicLib.nsh" # use of various logic statements
!include "WinVer.nsh" # LogicLib extension for OS tests
平台测试示例:
${if} ${AtLeastWin95}
${AndIf} ${AtMostWinME}
;here we are on a pre-win2k
;do something
${elseIf} ${isWin2008}
${orIf} ${AtLeastWin2008R2}
;this is post-win7
;do other thing
${endif}
要在运行时更改要安装的组件,可以使用Sections.nsh
:
;if you have
Section "Sample Database" SecApplicationDB
;...
SectionEnd
;you can select or un select by code:
!insertmacro SelectSection ${SecApplicationDB}
;or
!insertmacro UnselectSection ${SecApplicationDB}
答案 1 :(得分:1)
WinVer.nsh不支持检查Embedded NT,但您可以自己执行检查:
!include Sections.nsh
!include MUI.nsh
!ifndef VER_SUITE_EMBEDDEDNT
!define VER_SUITE_EMBEDDEDNT 0x00000040
!endif
!insertmacro MUI_PAGE_LICENSE "${__FILE__}"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
Section "Embedded" SID_EMBED
SectionIn RO
SectionEnd
Section "Normal" SID_NORMAL
SectionIn RO
SectionEnd
Function .onInit
System::Call '*(i156,&i152)i.r1'
System::Call 'KERNEL32::GetVersionExA(ir1)'
System::Call '*$1(&i152,&i2.r2)'
System::Free $1
IntOp $2 $2 & ${VER_SUITE_EMBEDDEDNT}
${If} $2 <> 0
!insertmacro SelectSection ${SID_EMBED}
!insertmacro UnselectSection ${SID_NORMAL}
${Else}
!insertmacro UnselectSection ${SID_EMBED}
!insertmacro SelectSection ${SID_NORMAL}
${EndIf}
FunctionEnd