!include "MUI2.nsh"
!include "LogicLib.nsh"
outfile "test.exe"
ShowInstDetails show
Caption "取消安装测试"
!define MUI_ABORTWARNING_TEXT "你确定终止安装?"
Var CompletedText
CompletedText $CompletedText
!insertmacro MUI_PAGE_WELCOME
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_PAGE_CUSTOMFUNCTION_PRE InstFilesPre
!define MUI_PAGE_CUSTOMFUNCTION_SHOW InstFilesShow
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE InstFilesLeave
Var MUI_HeaderText
Var MUI_HeaderSubText
!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "$MUI_HeaderText"
!define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT "$MUI_HeaderSubText"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_FINISH
Var CurrentPage
Var UserIsMakingAbortDecision
Var UserAborted
Var SectionAborted
Function PauseIfUserIsMakingAbortDecision
${DoWhile} $UserIsMakingAbortDecision == "yes"
Sleep 500
${Loop}
FunctionEnd
!define PauseIfUserIsMakingAbortDecision `Call PauseIfUserIsMakingAbortDecision`
!macro CheckUserAborted
${PauseIfUserIsMakingAbortDecision}
${If} $UserAborted == "yes"
goto _userabort_aborted
${EndIf}
!macroend
!define CheckUserAborted `!insertmacro CheckUserAborted`
!macro EndUserAborted
${CheckUserAborted}
goto _useraborted_end
_userabort_aborted:
${If} $SectionAborted == ""
StrCpy $SectionAborted "${__SECTION__}"
DetailPrint "${__SECTION__} 安装被中断"
${ElseIf} $SectionAborted != "${__SECTION__}"
DetailPrint " ${__SECTION__} 安装跳过。"
${EndIf}
_useraborted_end:
!macroend
!define EndUserAborted `!insertmacro EndUserAborted`
Function InstFilesPre
StrCpy $CurrentPage "InstFiles"
StrCpy $UserAborted "no"
FunctionEnd
Function InstFilesShow
GetDlgItem $0 $HWNDPARENT 2
EnableWindow $0 1
FunctionEnd
Section "Part One"
DetailPrint "安装 ${__SECTION__} A"
Sleep 1000
${CheckUserAborted}
DetailPrint "安装 ${__SECTION__} B"
Sleep 1000
${CheckUserAborted}
DetailPrint "安装 ${__SECTION__} C"
Sleep 1000
${EndUserAborted}
SectionEnd
Section "Part Two"
${CheckUserAborted}
DetailPrint "安装 ${__SECTION__} D"
Sleep 1000
${EndUserAborted}
SectionEnd
Section -"Post"
${If} $UserAborted == "yes"
StrCpy $CompletedText "安装已中止。"
StrCpy $MUI_HeaderText "安装失败"
StrCpy $MUI_HeaderSubText "安装程序中止。"
${Else}
StrCpy $CompletedText "已完成"
StrCpy $MUI_HeaderText "安装完成"
StrCpy $MUI_HeaderSubText "安装成功完成。"
${EndIf}
SectionEnd
Function InstFilesLeave
StrCpy $CurrentPage ""
FunctionEnd
!define MUI_CUSTOMFUNCTION_ABORT onUserAbort
Function onUserAbort
StrCpy $UserIsMakingAbortDecision "yes"
${If} ${Cmd} `MessageBox MB_YESNO|MB_DEFBUTTON2 "${MUI_ABORTWARNING_TEXT}" IDYES`
${If} $CurrentPage == "InstFiles"
StrCpy $UserAborted "yes"
MessageBox MB_OK "安装期间被终止。"
StrCpy $UserIsMakingAbortDecision "no"
Abort
${Else}
MessageBox MB_OK "其它安装界面终止"
StrCpy $UserIsMakingAbortDecision "no"
${EndIf}
${Else}
StrCpy $UserIsMakingAbortDecision "no"
Abort
${EndIf}
FunctionEnd
!insertmacro MUI_LANGUAGE "SimpChinese"
THE END
暂无评论内容