最新消息:

卸载加密码示例

nsis 永恒心锁 1526浏览 0评论
/*
 卸载加密码示例 by 永恒心锁
 */

!define PRODUCT_NAME "卸载加密码示例"
 !define PRODUCT_VERSION "1.0"
 !define PRODUCT_PUBLISHER "My company, Inc."
 !define PRODUCT_WEB_SITE "http://www.yhxs3344.net"
 !define PRODUCT_DIR_REGKEY "SoftwareMicrosoftWindowsCurrentVersionApp PathsAppMainExe.exe"
 !define PRODUCT_UNINST_KEY "SoftwareMicrosoftWindowsCurrentVersionUninstall${PRODUCT_NAME}"
 !define PRODUCT_UNINST_ROOT_KEY "HKLM"

SetCompressor lzma
 SetFont "tahoma" 8
 RequestExecutionLevel admin

!include "MUI2.nsh"

!define MUI_ABORTWARNING
 !define MUI_ICON "${NSISDIR}ContribGraphicsIconsmodern-install.ico"
 !define MUI_UNICON "${NSISDIR}ContribGraphicsIconsmodern-uninstall.ico"
 ;卸载密码
 !define Password "123"

!insertmacro MUI_PAGE_WELCOME
 !insertmacro MUI_PAGE_DIRECTORY
 !insertmacro MUI_PAGE_INSTFILES
 !insertmacro MUI_PAGE_FINISH

;卸载密码输入页面
 UninstPage Custom un.PasswordPageShow un.PasswordPageLeave
 !insertmacro MUI_UNPAGE_CONFIRM
 !insertmacro MUI_UNPAGE_INSTFILES

!insertmacro MUI_LANGUAGE "SimpChinese"

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
 OutFile "Setup.exe"
 InstallDir "$PROGRAMFILES卸载加密码示例"
 InstallDirRegKey HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
 ShowInstDetails show
 ShowUnInstDetails show

Section "MainSection" SEC01
 SetOutPath "$INSTDIR"
 SetOverwrite ifnewer
 CreateDirectory "$SMPROGRAMS卸载加密码示例"
 SectionEnd

Section -AdditionalIcons
 CreateDirectory "$SMPROGRAMS卸载加密码示例"
 CreateShortCut "$SMPROGRAMS卸载加密码示例Uninstall.lnk" "$INSTDIRuninst.exe"
 SectionEnd

Section -Post
 WriteUninstaller "$INSTDIRuninst.exe"
 WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIRAppMainExe.exe"
 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIRuninst.exe"
 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIRAppMainExe.exe"
 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
 SectionEnd

/******************************
 * 以下是安装程序的卸载部分 *
 ******************************/

Section Uninstall
 Delete "$INSTDIRuninst.exe"

Delete "$SMPROGRAMS卸载加密码示例Uninstall.lnk"

RMDir "$SMPROGRAMS卸载加密码示例"

RMDir "$INSTDIR"

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
 DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
 SetAutoClose true
 SectionEnd

Function un.onUninstSuccess
 HideWindow
 MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地从您的计算机移除。"
 FunctionEnd

;显示密码对话框
 Function un.PasswordPageShow
 !insertmacro MUI_HEADER_TEXT "输入密码" "卸载程序需要输入一个正确的密码以防止误操作。"
 PassDialog::InitDialog /NOUNLOAD Password /HEADINGTEXT "永恒心锁提示:卸载密码是123。" /GROUPTEXT "密码输入框"
 Pop $R0
 SendMessage $R1 ${EM_SETPASSWORDCHAR} 178 0
 PassDialog::Show
 FunctionEnd

;验证密码
 Function un.PasswordPageLeave
 ;从堆栈取出密码
 Pop $R0
 ;密码错误
 StrCmp $R0 '${Password}' +3
 MessageBox MB_OK|MB_ICONEXCLAMATION "密码输入错误!请输入正确的卸载密码!"
 Abort
 FunctionEnd
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » 卸载加密码示例

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