如何比较NSIS中的两个字符串

时间:2018-05-23 16:11:21

标签: nsis

我想在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}"

1 个答案:

答案 0 :(得分:3)

StrCmpStrCmpS指令可用于比较字符串:

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}