1. 程式人生 > >NSIS打包應用學習記

NSIS打包應用學習記

最近因為需要用到打包程式所以接觸了nsis和edit。前者是一個windows下的打包軟體,後者是它的ide。更具體的可以百度,要不是因為工作上需求,我還真的不想碰這個東西。現在差不多告以段落了。遂記錄一下,已做備忘。

接下來看一下程式碼。

; Script generated by the HM NIS Edit Script Wizard.
!define MULTIUSER_EXECUTIONLEVEL Highest
!include MultiUser.nsh
!include x64.nsh

!define PRODUCT_OEM_PATH "oem\CloudDisk"
#!define PRODUCT_OEM "LoongExplorer" !define PRODUCT_EXE_NAME "LDExplorer.exe" !define INSTALLDIR "CloudDisk" !define PRODUCT_NAME "CloudDisk" !define PRODUCT_PUBLISHER "" #!define PRODUCT_PUBLISHER "LoongStore Technology(Beijing) Co.,Ltd" #!define PRODUCT_EXE_NAME "LDExplorer.exe" #!define INSTALLDIR "XF CloudDisk"
#!define PRODUCT_NAME "XF CloudDisk" #!define PRODUCT_PUBLISHER "" !define PRODUCT_VERSION "5.10.3.0" #!define PRODUCT_PUBLISHER "LoongStore Technology(Beijing) Co.,Ltd" #!define PRODUCT_WEB_SITE "http://www.loongStore.com.cn" !define PRODUCT_WEB_SITE "" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\${PRODUCT_EXE_NAME}"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_ROOT_KEY "HKLM" !define INSTALL_VERSION "${PRODUCT_VERSION}" ; MUI 1.67 compatible ------ !include "MUI.nsh" ; MUI Settings #!define MUI_WELCOMEFINISHPAGE_BITMAP "${PRODUCT_OEM_PATH}\logo.bmp" !define MUI_ABORTWARNING !define MUI_ICON "${PRODUCT_OEM_PATH}\icon.ico" !define MUI_UNICON "${PRODUCT_OEM_PATH}\icon.ico" ; Language Selection Dialog Settings !define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}" !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}" !define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language" ; Welcome page !insertmacro MUI_PAGE_WELCOME ; License page !insertmacro MUI_PAGE_LICENSE "$(LNG_LICENSE)" ;"license.txt" ;!define MUI_COMPONENTSPAGE_NODESC ;!insertmacro MUI_PAGE_COMPONENTS ;Page components ; Directory page !insertmacro MUI_PAGE_DIRECTORY ; Instfiles page !insertmacro MUI_PAGE_INSTFILES ; Finish page !insertmacro MUI_PAGE_FINISH ; Uninstaller pages !insertmacro MUI_UNPAGE_INSTFILES ; Language files !insertmacro MUI_LANGUAGE "SimpChinese" ######################## !insertmacro MUI_LANGUAGE "English" ######################## ;LicenseLangString LNG_LICENSE ${LANG_ENGLISH} "${PRODUCT_OEM_PATH}\license.txt" LicenseLangString LNG_LICENSE ${LANG_SIMPCHINESE} "${PRODUCT_OEM_PATH}\license.txt" LangString LNG_TYPE ${LANG_ENGLISH} "E" LangString LNG_TYPE ${LANG_SIMPCHINESE} "C" LangString LNG_SEC_AD ${LANG_ENGLISH} "Auto login by AD user" LangString LNG_SEC_AD ${LANG_SIMPCHINESE} "鍩熸帶鐢ㄦ埛鑷姩鐧誨綍鐗? LangString LNG_SEC_NORMAL ${LANG_ENGLISH} "Normal user" LangString LNG_SEC_NORMAL ${LANG_SIMPCHINESE} "鏅€氱敤鎴風増" LangString LNG_USE_MSG ${LANG_ENGLISH} "Please exit ${PRODUCT_OEM} client,and then try again." LangString LNG_USE_MSG ${LANG_SIMPCHINESE} "媯€嫻嬪埌 ${PRODUCT_NAME} 姝e湪榪愯錛岃鍏抽棴涔嬪悗鍐嶆墽琛岋紒" LangString LNG_RESTART_MSG ${LANG_ENGLISH} "You must restart system to make ${PRODUCT_OEM} effective, are you sure to restart now?" LangString LNG_RESTART_MSG ${LANG_SIMPCHINESE} "涓轟簡浣?{PRODUCT_NAME}瀹㈡埛絝敓鏁堬紝浣犵殑緋葷粺闇€瑕侀噸鍚紝閫夋嫨鏄珛鍗抽噸鍚紝閫夋嫨鍚︾◢鍚庨噸鍚€? LangString LNG_UNINSTALL_MSG ${LANG_ENGLISH} " You must restart system in order to fully uninstall $(^Name), are you sure to restart now?" LangString LNG_UNINSTALL_MSG ${LANG_SIMPCHINESE} " 浣犲凡緇忔垚鍔熷嵏杞?(^Name)銆備負浜嗗畬鏁村嵏杞斤紝浣犵殑緋葷粺闇€瑕侀噸鍚紝閫夋嫨鏄珛鍗抽噸鍚紝閫夋嫨鍚︾◢鍚庨噸鍚? LangString LNG_UNINSTALL_CONFIRM_MSG ${LANG_ENGLISH} "are you sure qu inziu iosevka sa錛? LangString LNG_UNINSTALL_CONFIRM_MSG ${LANG_SIMPCHINESE} "鎮ㄧ‘瀹炶瀹屽叏縐婚櫎浜戠洏錛屽強鍏舵墍鏈夌殑緇勪歡錛? LangString LNG_INSTALL_MSG ${LANG_ENGLISH} "You have successfully installed $(^Name) on your computer." LangString LNG_INSTALL_MSG ${LANG_SIMPCHINESE} "浣犲凡緇忔垚鍔熷畨瑁?(^Name)銆? LangString LNG_CONFIRM_MSG ${LANG_ENGLISH} "Are you sure you want to uninstall $(^Name)?" LangString LNG_CONFIRM_MSG ${LANG_SIMPCHINESE} "浣犵‘瀹氳鍗歌澆 $(^Name)?" LangString LNG_DLL_MSG ${LANG_ENGLISH} "Failed to uninstall overlayIcon.dll" LangString LNG_DLL_MSG ${LANG_SIMPCHINESE} "鍗歌澆鍔ㄦ€侀摼鎺ュ簱overlayIcon.dll澶辮觸" LangString LNG_SAVE_USER_INFO_MSG ${LANG_ENGLISH} "to live user infosetting" LangString LNG_SAVE_USER_INFO_MSG ${LANG_SIMPCHINESE} "鏄惁淇濈暀鐢ㄦ埛閰嶇疆" LangString LNG_CHECK_ISNTALL_SOFTWARE ${LANG_ENGLISH} "Detected that the software has been installed, is it covered?" LangString LNG_CHECK_ISNTALL_SOFTWARE ${LANG_SIMPCHINESE} "媯€嫻嬪埌宸茬粡瀹夎杞歡,鏄惁瑕嗙洊?" LangString LNG_STOP_INSTALL ${LANG_ENGLISH} "Installation has been terminated." LangString LNG_STOP_INSTALL ${LANG_SIMPCHINESE} "瀹夎宸茬粓姝? LangString LNG_ISINSTALL_FIRST_UNINSTALL ${LANG_ENGLISH} "It is detected that the computer has been installed on the client. Please uninstall and then install!" LangString LNG_ISINSTALL_FIRST_UNINSTALL ${LANG_SIMPCHINESE} "媯€嫻嬪埌鐢佃剳宸茬粡瀹夎榪囧鎴風錛岃鍗歌澆鍚庡啀瀹夎!" VAR bAutoAD VAR bX64 VAR bRestart VIProductVersion "${PRODUCT_VERSION}" VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "ProductName" "${PRODUCT_NAME}" VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "CompanyName" "${PRODUCT_PUBLISHER}" VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "LegalCopyright" "" #VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "LegalCopyright" "Copyright (C) LoongStore Corporation.All rights reserved." VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "FileDescription" "${PRODUCT_NAME}" VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "FileVersion" "${PRODUCT_VERSION}" VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "ProductVersion" "${PRODUCT_VERSION}" BrandingText "${PRODUCT_PUBLISHER}" ; MUI end ------ Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "${PRODUCT_NAME}_${PRODUCT_VERSION}.exe" InstallDir "$PROGRAMFILES\${PRODUCT_NAME}" InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" ShowInstDetails show ShowUnInstDetails show Section SectionIn RO ProcessWork::existsprocess "${PRODUCT_EXE_NAME}" Pop $R0 IntCmp $R0 1 0 no_run MessageBox MB_ICONSTOP|MB_OK $(LNG_USE_MSG) IDOK +1 Quit no_run: IfFileExists $INSTDIR\_AES.pyd 0 +5 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 $(LNG_CHECK_ISNTALL_SOFTWARE) IDYES +9 HideWindow MessageBox MB_ICONINFORMATION|MB_OK $(LNG_STOP_INSTALL) Quit ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\${PRODUCT_NAME}" "" IfErrors 0 +2 Goto +3 MessageBox MB_ICONSTOP $(LNG_ISINSTALL_FIRST_UNINSTALL) Quit SetOutPath "$INSTDIR" SetOverwrite on File "${PRODUCT_OEM_PATH}\${PRODUCT_EXE_NAME}" File "common\*" File /r "common\*.*" ############################################ ${If} $(LNG_TYPE) == "E" Delete "$INSTDIR\trans.qm" ${EndIf} ############################################ CreateDirectory "$INSTDIR\RMenu" IfFileExists "$INSTDIR\RMenu\OverlayIcon.dll" 0 +3 Rename "$INSTDIR\RMenu\OverlayIcon.dll" "$TEMP\OverlayIcon.dll" Delete /REBOOTOK "$TEMP\OverlayIcon.dll" IfFileExists "$INSTDIR\RMenu\Ctxmenu.dll" 0 +3 Rename "$INSTDIR\RMenu\Ctxmenu.dll" "$TEMP\Ctxmenu.dll" Delete /REBOOTOK "$TEMP\Ctxmenu.dll" ${If} $bX64 == "1" File "/oname=$INSTDIR\RMenu\OverlayIcon.dll" "RMenu\amd64\OverlayIcon.dll" File "/oname=$INSTDIR\RMenu\Ctxmenu.dll" "RMenu\amd64\Ctxmenu.dll" File "driver\amd64\lsSetUp.exe" ${DisableX64FSRedirection} ${If} $(LNG_TYPE) == "C" File "/oname=$SYSDIR\ldres.dll" "${PRODUCT_OEM_PATH}\amd64\ldres.dll" ${Else} File "/oname=$SYSDIR\ldres.dll" "${PRODUCT_OEM_PATH}\amd64\en\ldres.dll" ${EndIf} ${Else} File "/oname=$INSTDIR\RMenu\OverlayIcon.dll" "RMenu\i386\OverlayIcon.dll" File "/oname=$INSTDIR\RMenu\Ctxmenu.dll" "RMenu\i386\Ctxmenu.dll" File "driver\i386\lsSetUp.exe" ${If} $(LNG_TYPE) == "C" File "/oname=$SYSDIR\ldres.dll" "${PRODUCT_OEM_PATH}\i386\ldres.dll" ${Else} File "/oname=$SYSDIR\ldres.dll" "${PRODUCT_OEM_PATH}\i386\en\ldres.dll" ${EndIf} ${EndIf} File "/oname=$INSTDIR\RMenu\LockOther.ico" "RMenu\LockOther.ico" File "/oname=$INSTDIR\RMenu\LockOwner.ico" "RMenu\LockOwner.ico" CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}" CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_EXE_NAME}" CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_EXE_NAME}" Call loadDriver SectionEnd Section /o $(LNG_SEC_AD) g1o1 strcpy $bAutoAD "1" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "ldGui" "$INSTDIR\${PRODUCT_EXE_NAME} /login" SectionEnd Section /o $(LNG_SEC_NORMAL) g1o2 strcpy $bAutoAD "0" SectionEnd Section -AdditionalIcons SetOutPath $INSTDIR WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url" CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk" "$INSTDIR\uninst.exe" SectionEnd Section -Post WriteUninstaller "$INSTDIR\uninst.exe" WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\${PRODUCT_EXE_NAME}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\${PRODUCT_EXE_NAME}" 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}" WriteRegStr HKLM "System\CurrentControlSet\Services\Lspfsd" "Server" "10.11.0.42" WriteRegStr HKLM "System\CurrentControlSet\Services\Lspfsd" "dns" "" WriteRegStr HKLM "System\CurrentControlSet\Services\Lspfsd" "filter" "*.EXE" WriteRegDWORD HKLM "System\CurrentControlSet\Services\Lspfsd" "Port" 8000 WriteRegDWORD HKLM "System\CurrentControlSet\Services\Lspfsd" "TimeOut" 10000 WriteRegDWORD HKLM "System\CurrentControlSet\Services\Lspfsd" "DelayTime" 3000 WriteRegDWORD HKLM "System\CurrentControlSet\Services\Lspfsd" "FTValue" 0x00FF ${If} $bAutoAD == "1" WriteRegDWORD HKLM "System\CurrentControlSet\Services\Lspfsd" "Flags" 0x00001010 WriteRegDWORD HKLM "System\CurrentControlSet\Services\Lspfsd" "clientMask" 0x12 ${Else} WriteRegDWORD HKLM "System\CurrentControlSet\Services\Lspfsd" "Flags" 0x00001012 WriteRegDWORD HKLM "System\CurrentControlSet\Services\Lspfsd" "clientMask" 0x14 ${EndIf} WriteRegDWORD HKLM "System\CurrentControlSet\Services\Lspfsd" "Version" 7002 ExecWait 'regsvr32 /s /c "$INSTDIR\RMenu\OverlayIcon.dll"' ExecWait 'regsvr32 /s /c "$INSTDIR\RMenu\CtxMenu.dll"' SectionEnd Function .onInit !insertmacro MULTIUSER_INIT ###################### !insertmacro MUI_LANGDLL_DISPLAY ###################### ${If} ${RunningX64} strcpy $bX64 "1" ${Else} strcpy $bX64 "0" ${EndIf} strcpy $bRestart "0" StrCpy $1 ${g1o2} FunctionEnd Function .onSelChange !insertmacro StartRadioButtons $1 !insertmacro RadioButton ${g1o1} !insertmacro RadioButton ${g1o2} !insertmacro EndRadioButtons FunctionEnd Function loadDriver SetOutPath "$SYSDIR\drivers" SetOverwrite on ${If} $bX64 == "1" ${DisableX64FSRedirection} ${EndIf} IfFileExists "$SYSDIR\drivers\lspFsd.sys" 0 +4 Rename "$SYSDIR\drivers\lspFsd.sys" "$TEMP\lspfsd.sys" Delete /REBOOTOK "$TEMP\lspfsd.sys" strcpy $bRestart "1" ${If} $bX64 == "1" ${If} ${AtMostWin2008R2} File "/oname=$SYSDIR\drivers\lspfsd.sys" "driver\amd64\5.x-6.0\lspFsd.sys" ${Else} File "/oname=$SYSDIR\drivers\lspfsd.sys" "driver\amd64\6.1\lspFsd.sys" ${EndIf} ${Else} ${If} ${AtMostWin2008R2} File "driver\i386\5.x-6.0\lspfsd.sys" ${ELSE} File "driver\i386\6.1\lspfsd.sys" ${ENDIF} ${EndIf} ${If} $bRestart == "0" #ExecWait "$INSTDIR\lsSetUp.exe Add 2 ${PRODUCT_NAME}" ExecWait "$INSTDIR\lsSetUp.exe Add 2 LoongDisk" ${EndIf} FunctionEnd Function un.unloadDriver ExecWait "$INSTDIR\lsSetUp.exe remove 2 LoongDisk" #ExecWait "$INSTDIR\lsSetUp.exe remove 2 ${PRODUCT_NAME}" ${If} $bX64 == "1" ${DisableX64FSRedirection} ${EndIf} Rename "$SYSDIR\drivers\lspFsd.sys" "$TEMP\lspfsd.sys" Delete /REBOOTOK "$TEMP\lspfsd.sys" FunctionEnd Function .onInstSuccess ${If} $bRestart == "1" IfSilent +2 MessageBox MB_ICONINFORMATION|MB_YESNO $(LNG_RESTART_MSG) IDNO +2 Reboot ${Else} IfSilent +3 MessageBox MB_OK $(LNG_INSTALL_MSG) ExecWait "$INSTDIR\ldtool /restart" ${EndIf} FunctionEnd Function un.onUninstSuccess MessageBox MB_ICONINFORMATION|MB_YESNO $(LNG_UNINSTALL_MSG) IDNO +2 Reboot FunctionEnd Function un.onInit !insertmacro MULTIUSER_UNINIT !insertmacro MUI_UNGETLANGUAGE ################################################### #MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 $(LNG_UNINSTALL_CONFIRM_MSG) IDYES +2 #Abort #ProcessWork::existsprocess "${PRODUCT_EXE_NAME}" #Pop $R0 #IntCmp $R0 1 0 no_run #MessageBox MB_ICONSTOP|MB_RETRYCANCEL|MB_DEFBUTTON2 $(LNG_USE_MSG) IDRETRY -3 #Quit #no_run: #${If} ${RunningX64} # strcpy $bX64 "1" #${Else} # strcpy $bX64 "0" #${EndIf}''' ################################################### FunctionEnd Section Uninstall ################################################### MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 $(LNG_UNINSTALL_CONFIRM_MSG) IDYES +2 Abort ProcessWork::existsprocess "${PRODUCT_EXE_NAME}" Pop $R0 IntCmp $R0 1 0 no_run MessageBox MB_ICONSTOP|MB_RETRYCANCEL|MB_DEFBUTTON2 $(LNG_USE_MSG) IDRETRY -3 Quit no_run: ${If} ${RunningX64} strcpy $bX64 "1" ${Else} strcpy $bX64 "0" ${EndIf} #################################################### ExecWait 'regsvr32 /s /u "$INSTDIR\RMenu\OverlayIcon.dll"' $0 ${If} $0 != 0 MessageBox MB_ICONSTOP|MB_OK $(LNG_DLL_MSG) IDOK +1 Abort ${EndIf} ExecWait 'regsvr32 /s /u "$INSTDIR\RMenu\CtxMenu.dll"' Rename "$INSTDIR\RMenu\OverlayIcon.dll" "$TEMP\OverlayIcon.dll" Rename "$INSTDIR\RMenu\Ctxmenu.dll" "$TEMP\Ctxmenu.dll" Delete /REBOOTOK "$TEMP\OverlayIcon.dll" Delete /REBOOTOK "$TEMP\Ctxmenu.dll" Call un.unloadDriver MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 $(LNG_SAVE_USER_INFO_MSG) IDYES +3 ReadEnvStr $R9 UserName RMDir /r "C:\Users\$R9\AppData\Local\${INSTALLDIR}" RMDir /r "$INSTDIR\UserData" RMDir /r "$INSTDIR\sqldrivers" RMDir /r "$INSTDIR\skin" RMDir /r "$INSTDIR\platforms" RMDir /r "$INSTDIR\picture" RMDir /r "$INSTDIR\imageformats" RMDir /r "$INSTDIR\DLLs" RMDir /r "$INSTDIR\RMenu" Delete "$INSTDIR\${PRODUCT_NAME}.url" Delete "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk" Delete "$SMPROGRAMS\${PRODUCT_NAME}\Website.lnk" Delete "$DESKTOP\${PRODUCT_NAME}.lnk" Delete "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" RMDir "$SMPROGRAMS\${PRODUCT_NAME}" RMDir /r "$INSTDIR" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}" DeleteRegKey HKLM "System\CurrentControlSet\Services\Lspfsd" DeleteRegKey HKCU "Software\${PRODUCT_NAME}" DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "ldGui" SetAutoClose true SectionEnd ###

!define設定了變數。版本號,登錄檔路徑等。
!insertmacro 定義了mui的gui介面。
section 是執行的動作,可以理解成函式,順序執行。
ifxxx 0 +num 0一般是出現的標誌,比如iferror 如果出現了error 則執行下面的程式碼,如果沒有則執行後面的跳轉num。goto可以用在任何地方跳轉。
messagebox 是彈出視窗,-post是寫入登錄檔。

ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\LoongDiskExplorer.exe" ""

這裡如果你遇到了跟我一樣把app paths識別成了兩個引數的話,那麼就把他們用”括起來即可。

ProcessWork::existsprocess "LoongDiskExplorer.exe"
    Pop $R0
    IntCmp $R0 1 0 no_run
    MessageBox MB_ICONSTOP "解除安裝程式檢測到 $R0 ${PRODUCT_NAME} 正在執行,請關閉之後再解除安裝!"
    Quit
    no_run:

重點說一下這裡,如果你去查網上的程式碼,也許查到的都是用另一個擴充套件,那個擴充套件有一個問題,就是不能支援64位程序的檢測,所以改用這個擴充套件,程式碼複製即可用,改動相應位置變數即可。pop接收的擴充套件檢測到程序的時候彈出的變數,不同的變數對應著不同的情況。

update:關於多語言國際化問題,首先我查到可以用

!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_LANGUAGE "English"

!insertmacro MUI_LANGDLL_DISPLAY
LangString LNG_TYPE ${LANG_ENGLISH} "E"
LangString LNG_TYPE ${LANG_SIMPCHINESE} "C"

來進行安裝開始的選擇語言,其中文字用 langstring進行自動替換,
然後所有的gui介面確實變成了相應的中英文,但是這個有兩個問題,第一就是在英文系統下,中文是亂碼,二是所有的msgbox的button都是隨系統變化的。於是開始搜尋亂碼問題,到這裡可以合理的猜測是 編碼問題,點選這裡可以下載unicode版的nsis編譯器,然後如果你那幢了nvis的那個ide,記得配置編譯選項定位到unicode版,編譯即可。如果沒有問題可以不用往下看了

如果你發現gui雖然不會再有編碼問題,但是你的所有msgbox的中文全部變成了亂碼,那麼就是你的nsi文字本身的編碼有問題,這個具體可以看編譯的log,

has no BOM and does not validate as UTF-8.

大約這樣的資訊,這時問題就變的簡單了,把nsi檔案檔案程式設計utf8編碼即可,下載notepad轉換編碼儲存,結束。這個問題困擾了我兩天,希望能對看到這裡的朋友有所幫助~

以上就是我折騰了幾天的收穫,願大家越過山丘!