杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2122|回复: 0

NSIS:卸载加密码示例

[复制链接]
发表于 2015-2-3 22:16:40 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. /*
  2. 卸载加密码示例 by 少轻狂
  3. 轻狂志http://www.flighty.cn/html/bushu/20140314_226.html
  4. */

  5. !define PRODUCT_NAME "卸载加密码示例"
  6. !define PRODUCT_VERSION "1.0"
  7. !define PRODUCT_PUBLISHER "My company, Inc."
  8. !define PRODUCT_WEB_SITE "http://www.flighty.cn"
  9. !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\AppMainExe.exe"
  10. !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
  11. !define PRODUCT_UNINST_ROOT_KEY "HKLM"

  12. SetCompressor lzma
  13. SetFont "tahoma" 8
  14. RequestExecutionLevel admin

  15. !include "MUI2.nsh"

  16. !define MUI_ABORTWARNING
  17. !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
  18. !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
  19. ;卸载密码
  20. !define Password "123"

  21. !insertmacro MUI_PAGE_WELCOME
  22. !insertmacro MUI_PAGE_DIRECTORY
  23. !insertmacro MUI_PAGE_INSTFILES
  24. !insertmacro MUI_PAGE_FINISH

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

  29. !insertmacro MUI_LANGUAGE "SimpChinese"

  30. Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
  31. OutFile "Setup.exe"
  32. InstallDir "$PROGRAMFILES\卸载加密码示例"
  33. InstallDirRegKey HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
  34. ShowInstDetails show
  35. ShowUnInstDetails show

  36. Section "MainSection" SEC01
  37.   SetOutPath "$INSTDIR"
  38.   SetOverwrite ifnewer
  39.   CreateDirectory "$SMPROGRAMS\卸载加密码示例"
  40. SectionEnd

  41. Section -AdditionalIcons
  42.   CreateDirectory "$SMPROGRAMS\卸载加密码示例"
  43.   CreateShortCut "$SMPROGRAMS\卸载加密码示例\Uninstall.lnk" "$INSTDIR\uninst.exe"
  44. SectionEnd

  45. Section -Post
  46.   WriteUninstaller "$INSTDIR\uninst.exe"
  47.   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\AppMainExe.exe"
  48.   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
  49.   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
  50.   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\AppMainExe.exe"
  51.   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  52.   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  53.   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
  54. SectionEnd

  55. /******************************
  56. *  以下是安装程序的卸载部分  *
  57. ******************************/

  58. Section Uninstall
  59.   Delete "$INSTDIR\uninst.exe"

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

  61.   RMDir "$SMPROGRAMS\卸载加密码示例"

  62.   RMDir "$INSTDIR"

  63.   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  64.   DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
  65.   SetAutoClose true
  66. SectionEnd

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

  71. ;显示密码对话框
  72. Function un.PasswordPageShow
  73.   !insertmacro MUI_HEADER_TEXT "输入密码" "卸载程序需要输入一个正确的密码以防止误操作。"
  74.   PassDialog::InitDialog /NOUNLOAD Password /HEADINGTEXT "少轻狂提示:卸载密码是123。" /GROUPTEXT "密码输入框"
  75.   Pop $R0
  76.   SendMessage $R1 ${EM_SETPASSWORDCHAR} 178 0
  77.   PassDialog::Show
  78. FunctionEnd

  79. ;验证密码
  80. Function un.PasswordPageLeave
  81.   ;从堆栈取出密码
  82.   Pop $R0
  83.   ;密码错误
  84.   StrCmp $R0 '${Password}' +3
  85.   MessageBox MB_OK|MB_ICONEXCLAMATION "密码输入错误!请输入正确的卸载密码!"
  86.   Abort
  87. FunctionEnd
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-5-17 21:12 , Processed in 0.120016 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表