最新消息:

终止InstFiles安装页面

nsis 永恒心锁 2617浏览 0评论
!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"
免责声明:根据《计算机软件保护条例》第十七条规定“为了学习和研究软件内含的设计思想和原理,通过安装、显示、传输或者存储软件等方式使用软件的,可以不经软件著作权人许可,不向其支付报酬。”您需知晓本站所有内容资源均来源于网络,仅供用户交流学习与研究使用,版权归属原版权方所有,版权争议与本站无关,用户本人下载后不能用作商业或非法用途,需在24个小时之内从您的电脑中彻底删除上述内容,否则后果均由用户承担责任;如果您访问和下载此文件,表示您同意只将此文件用于参考、学习而非其他用途,否则一切后果请您自行承担,如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。丨本站为个人博客非盈利性站点,所有软件信息均来自网络,所有资源仅供学习参考研究目的,并不贩卖软件,不存在任何商业目的及用途。丨本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » 终止InstFiles安装页面

您必须 登录 才能发表评论!