如何获取INSTALLOPTIONS_DISPLAY_RETURN的返回值?

时间:2017-12-05 15:22:00

标签: nsis

如果单击后底部,我会尝试获取,并避免在未填写其中一个输入时显示错误消息。

Rigth现在$ R9变量没有按照我的预期提交。

Function SetCustom

  ;SectionGetFlags ${SEC04} $R0
  SectionGetFlags ${SEC05} $R5
  SectionGetFlags ${SEC06} $R6
  SectionGetFlags ${SEC07} $R7
  IntOp $R0 $R0 & ${SF_SELECTED}
  IntOp $R5 $R5 & ${SF_SELECTED}
  IntOp $R6 $R6 & ${SF_SELECTED}
  IntOp $R7 $R7 & ${SF_SELECTED}
  IntCmp $R0 ${SF_SELECTED} show
  IntCmp $R5 ${SF_SELECTED} show
  IntCmp $R6 ${SF_SELECTED} show
  IntCmp $R7 ${SF_SELECTED} show

  Abort

  show:
    Input:
    !insertmacro MUI_HEADER_TEXT "Customization" "Please input the Info1 and Info2 of the Customization user."
    !insertmacro MUI_INSTALLOPTIONS_DISPLAY "File.ini"
    !insertmacro INSTALLOPTIONS_READ $R1 "File.ini" "Field 2" "State"
    !insertmacro INSTALLOPTIONS_READ $R2 "File.ini" "Field 3" "State"
    ;!insertmacro INSTALLOPTIONS_SHOW_RETURN
    !insertmacro INSTALLOPTIONS_DISPLAY_RETURN $R9

    MessageBox MB_OK "$R9"
    ${If} "$R9" == "back"
        Abort
     ${Else}    
        StrCmp $R1 "" 0 +3
        MessageBox MB_ICONEXCLAMATION|MB_OK "Please enter a Info1."
        Goto Input

        StrCmp $R2 "" 0 +3
        MessageBox MB_ICONEXCLAMATION|MB_OK "Please enter a Info2"
        Goto Input
    ${EndIf}
FunctionEnd

2 个答案:

答案 0 :(得分:0)

文档告诉您Pop

  

如果需要返回值,请使用INSTALLOPTIONS_DISPLAY_RETURN或INSTALLOPTIONS_SHOW_RETURN宏。返回值将被添加到堆栈中,因此您可以使用Pop命令来获取它。

!insertmacro INSTALLOPTIONS_DISPLAY_RETURN "File.ini"
Pop $5
${If} $5 == "back"
  ...
${EndIf}

答案 1 :(得分:0)

从我的阅读中,有一封 pengyou 的帖子可以在这里找到:

https://nsis-dev.github.io/NSIS-Forums/html/t-182393.html

帖子要求更改用于调用页面显示的功能。

我将所有呼叫更改为使用其 MUI 版本,并使用 MUI_INSTALLOPTIONS_DISPLAY_RETURN 代替了 MUI_INSTALLOPTIONS_DISPLAY

我也将调用ini文件的顺序更改为在配置之前完成。

Function SetCustom      
  SectionGetFlags ${SEC01} $R0
  SectionGetFlags ${SEC02} $R4
  SectionGetFlags ${SEC03} $R5
  IntOp $R0 $R0 & ${SF_SELECTED}
  IntOp $R4 $R4 & ${SF_SELECTED}
  IntOp $R5 $R5 & ${SF_SELECTED}
  IntCmp $R0 ${SF_SELECTED} show
  IntCmp $R4 ${SF_SELECTED} show
  IntCmp $R5 ${SF_SELECTED} show
  
  Abort
    
    show:
    InputMySQL:
    
    StrCpy $UserAborted "0"
    !insertmacro MUI_INSTALLOPTIONS_DISPLAY_RETURN "file.ini"
    !insertmacro MUI_HEADER_TEXT "MySQL customization" "Please input the username and password of the MySQL user."
    
    !insertmacro MUI_INSTALLOPTIONS_READ $R1 "file.ini" "Field 2" "State"
    !insertmacro MUI_INSTALLOPTIONS_READ $R2 "file.ini" "Field 3" "State"
    !insertmacro MUI_INSTALLOPTIONS_READ $R3 "file.ini" "Field 4" "State"
    
    Pop $R6
    
    MessageBox MB_OK "$R6" ;This will pop a message box comment it out for debugging
        

        ${If} $R6 <> "back"
            ${If} $R6 <> "cancel"
                ;Do validation code here
            ${EndIf}
        ${EndIf}
FunctionEnd