我尝试使用以下代码
; The default installation directory
InstallDir $PROGRAMFILES\${PRODUCT_NAME}
to
!include x64.nsh
${If} ${RunningX64}
; The default installation directory
InstallDir $PROGRAMFILES\${PRODUCT_NAME}
${Else}
; The default installation directory
InstallDir $PROGRAMFILES64\${PRODUCT_NAME}
${EndIf}
我收到以下错误:-
!insertmacro: _If
Error: Can't add entry, no section or function is open!
Error in macro _RunningX64 on macroline 2
Error in macro _If on macroline 9
Error in script "C:\Users\yccheok\Desktop\mysoftware.nsi" on line 17 -- aborting creation process
有什么方法可以设置该值InstallDir
,在 if else 块内?
如果您需要动态 $InstDir,则根本不应该使用 InstallDir,而应在 .onInit 中设置 $InstDir:
Installdir ""
!include LogicLib.nsh
!include x64.nsh
Function .onInit
${If} $InstDir == "" ; /D= was not used on the command line
${If} ${RunningX64}
StrCpy $InstDir "c:\foo"
${Else}
StrCpy $InstDir "c:\bar"
${EndIf}
${EndIf}
FunctionEnd
您当前的 if else 块没有任何意义,因为您选择的是 x64 上的 32 位程序文件和 x86 上的 64 位程序文件!在 x86 上使用 $PROGRAMFILES64 是可以的,所以如果你总是想要“真正的”程序文件,你可以在所有平台上使用 $PROGRAMFILES64...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)