我想在NSIS中比较两个字符串,例如。如果为以下代码做了if else条件。
ReadRegStr $R0 HKLM "${PRODUCT_UNINST_KEY}" "InstallLocation"
if ;$R0 has some values then it needs to be copied else this " $INSTDIR "$PROGRAMFILES64\${PRODUCT_NAME}""values should be assigned to INSTDIR
StrCpy $INSTDIR "$R0"
else
StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCT_NAME}"
答案 0 :(得分:3)
StrCmp
和StrCmpS
指令可用于比较字符串:
StrCmp $myvar "somestring" 0 jump_to_if_not_equal
DetailPrint "myvar was somestring"
goto end
jump_to_if_not_equal:
DetailPrint "not a match"
end:
您也可以使用LogicLib助手宏:
!include LogicLib.nsh
${If} $myvar == "something"
DetailPrint "match"
${Else}
DetailPrint "not a match"
${EndIf}