最新消息:

实现多语言安装卸载并定义语言相关字符串

nsis 永恒心锁 1948浏览 0评论
!define PRODUCT_NAME ""
 !define PRODUCT_VERSION "1.0"
 !define PRODUCT_PUBLISHER "My company, Inc."
 !define PRODUCT_WEB_SITE "http://www.yhxs3344.net"
 !define PRODUCT_UNINST_KEY "SoftwareMicrosoftWindowsCurrentVersionUninstallmyapp"
 !define PRODUCT_UNINST_ROOT_KEY "HKLM"

SetCompressor lzma
 RequestExecutionLevel admin

!include "MUI2.nsh"

!define MUI_ABORTWARNING
 !define MUI_ICON "${NSISDIR}ContribGraphicsIconsmodern-install.ico"
 !define MUI_UNICON "${NSISDIR}ContribGraphicsIconsmodern-uninstall.ico"

; 语言选择窗口常量设置
 !define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
 !define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"

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

!insertmacro MUI_UNPAGE_INSTFILES

; 语言设置
 !insertmacro MUI_LANGUAGE "English"
 !insertmacro MUI_LANGUAGE "SimpChinese"
 ; 语言相关字符串
 LangString LNG_AppName ${LANG_ENGLISH} "flighty'app"
 LangString LNG_AppName ${LANG_SIMPCHINESE} "轻狂的程序"
 LangString UNINSTALL_CONFIRM ${LANG_ENGLISH} "Thank you very much! $(^Name) has been successfully removed."
 LangString UNINSTALL_CONFIRM ${LANG_SIMPCHINESE} "非常感謝您的使用! $(^Name) 已成功地从您的计算机中移除。"
 Name "$(LNG_AppName)"
 OutFile "Setup.exe"
 InstallDir "$PROGRAMFILESMy application"
 ShowInstDetails show
 ShowUnInstDetails show

Section "MainSection" SEC01
 StrCpy $0 $(LNG_AppName)
 ${If} $0 == "flighty'app"
 MessageBox MB_OK "ENGLISH"
 ${Else}
 MessageBox MB_OK "简体中文"
 ${EndIf}
 SectionEnd

Section -AdditionalIcons
 SetOutPath $INSTDIR
 WriteIniStr "$INSTDIR${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
 CreateDirectory "$SMPROGRAMSMy application"
 CreateShortCut "$SMPROGRAMSMy applicationWebsite.lnk" "$INSTDIR${PRODUCT_NAME}.url"
 CreateShortCut "$SMPROGRAMSMy applicationUninstall.lnk" "$INSTDIRuninst.exe"
 SectionEnd

Section -Post
 WriteUninstaller "$INSTDIRuninst.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}" "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
 Function .onInit
 !insertmacro MUI_LANGDLL_DISPLAY
 FunctionEnd

Section Uninstall
 Delete "$INSTDIR${PRODUCT_NAME}.url"
 Delete "$INSTDIRuninst.exe"

Delete "$SMPROGRAMSMy applicationUninstall.lnk"
 Delete "$SMPROGRAMSMy applicationWebsite.lnk"

RMDir "$SMPROGRAMSMy application"

RMDir "$INSTDIR"

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

Function un.onInit
 !insertmacro MUI_UNGETLANGUAGE
 FunctionEnd

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

转载请注明:永恒心锁-分享互联网 » 实现多语言安装卸载并定义语言相关字符串

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