⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 installer.nsi

📁 现在很火的邮件客户端软件thunderbird的源码
💻 NSI
📖 第 1 页 / 共 3 页
字号:
  StrCpy $TmpVal "$INSTDIR\uninstall\$TmpVal"  FindNext $0 $1  StrCmp $1 "" cleanup  StrCpy $1 "$INSTDIR\uninstall\$1"  Push $1  Call DiffOldLogFiles  FindClose $0  ${DeleteFile} "$1"  cleanup:    StrCpy $2 "$INSTDIR\uninstall\cleanup.log"    ${DeleteFile} "$2"    FileOpen $R2 $2 w    Push $TmpVal    ${LineFind} "$INSTDIR\uninstall\$TmpVal" "/NUL" "1:-1" "CleanOldLogFilesCallback"    ${DeleteFile} "$INSTDIR\uninstall\$TmpVal"  done:    FindClose $0    FileClose $R2    FileClose $R3FunctionEndFunction DiffOldLogFiles  StrCpy $R1 "$1"  GetTempFileName $R2  FileOpen $R3 $R2 w  ${TextCompareNoDetails} "$R1" "$TmpVal" "SlowDiff" "GetDiff"  FileClose $R3  ${FileJoin} "$TmpVal" "$R2" "$TmpVal"  ${DeleteFile} "$R2"FunctionEndFunction CleanOldLogFilesCallback  ${TrimNewLines} "$R9" $R9  ${WordReplace} "$R9" "$INSTDIR" "" "+" $R3  ${WordFind} "$R9" "	" "E+1}" $R0  IfErrors updater 0  ${WordFind} "$R0" "Installing: " "E+1}" $R1  ${Unless} ${Errors}    FileWrite $R2 "File: $R1$\r$\n"    GoTo done  ${EndUnless}  ${WordFind} "$R0" "Replacing: " "E+1}" $R1  ${Unless} ${Errors}    FileWrite $R2 "File: $R1$\r$\n"    GoTo done  ${EndUnless}  ${WordFind} "$R0" "Windows Shortcut: " "E+1}" $R1  ${Unless} ${Errors}    FileWrite $R2 "File: $R1.lnk$\r$\n"    GoTo done  ${EndUnless}  ${WordFind} "$R0" "Create Folder: " "E+1}" $R1  ${Unless} ${Errors}    FileWrite $R2 "Dir: $R1$\r$\n"    GoTo done  ${EndUnless}  updater:    ${WordFind} "$R9" "installing: " "E+1}" $R0    ${Unless} ${Errors}      FileWrite $R2 "File: $R0$\r$\n"    ${EndUnless}  done:    Push 0FunctionEndFunction LaunchApp  ${CloseApp} "true" $(WARN_APP_RUNNING_INSTALL)  Exec "$INSTDIR\${FileMainEXE}"FunctionEnd################################################################################# Language!insertmacro MOZ_MUI_LANGUAGE 'baseLocale'!verbose push!verbose 3!include "overrideLocale.nsh"!include "customLocale.nsh"!verbose pop; Set this after the locale files to override it if it is in the locale; using " " for BrandingText will hide the "Nullsoft Install System..." brandingBrandingText " "################################################################################# Page pre and leave functionsFunction preOptions  !insertmacro MUI_HEADER_TEXT "$(OPTIONS_PAGE_TITLE)" "$(OPTIONS_PAGE_SUBTITLE)"  !insertmacro MUI_INSTALLOPTIONS_DISPLAY "options.ini"FunctionEndFunction leaveOptions  ${MUI_INSTALLOPTIONS_READ} $0 "options.ini" "Settings" "State"  ${If} $0 != 0    Abort  ${EndIf}  ${MUI_INSTALLOPTIONS_READ} $R0 "options.ini" "Field 2" "State"  StrCmp $R0 "1" +1 +2  StrCpy $InstallType "1"  ${MUI_INSTALLOPTIONS_READ} $R0 "options.ini" "Field 3" "State"  StrCmp $R0 "1" +1 +2  StrCpy $InstallType "4"FunctionEndFunction preComponents  Call CheckCustom  ; If DOMi isn't available skip the components page  ${Unless} ${FileExists} "$EXEDIR\optional\extensions\inspector@mozilla.org"    Abort  ${EndUnless}  !insertmacro MUI_HEADER_TEXT "$(OPTIONAL_COMPONENTS_TITLE)" "$(OPTIONAL_COMPONENTS_SUBTITLE)"  !insertmacro MUI_INSTALLOPTIONS_DISPLAY "components.ini"FunctionEndFunction leaveComponents  ; If DOMi exists then it will be Field 2.  ; If DOMi doesn't exist and talkback exists then TalkBack will be Field 2 but  ; if DOMi doesn't exist we won't display this page anyways.  StrCpy $R1 2  ${If} ${FileExists} "$EXEDIR\optional\extensions\inspector@mozilla.org"    ${MUI_INSTALLOPTIONS_READ} $R0 "components.ini" "Field $R1" "State"    ; State will be 1 for checked and 0 for unchecked so we can use that to set    ; the section flags for installation.    SectionSetFlags 1 $R0    IntOp $R1 $R1 + 1  ${Else}    SectionSetFlags 1 0 ; Disable install for DOMi  ${EndIf}  ${If} ${FileExists} "$EXEDIR\optional\extensions\talkback@mozilla.org"    ${MUI_INSTALLOPTIONS_READ} $R0 "components.ini" "Field $R1" "State"    ; State will be 1 for checked and 0 for unchecked so we can use that to set    ; the section flags for installation.    SectionSetFlags 2 $R0  ${Else}    SectionSetFlags 2 0 ; Disable install for TalkBack  ${EndIf}FunctionEndFunction preDirectory  ${If} $InstallType != 4    ${CheckDiskSpace} $R9    ${If} $R9 != "false"      ${CanWriteToInstallDir} $R9      ${If} $R9 != "false"        Abort      ${EndIf}    ${EndIf}  ${EndIf}FunctionEndFunction leaveDirectory  ${CheckDiskSpace} $R9  ${If} $R9 == "false"    MessageBox MB_OK "$(WARN_DISK_SPACE)"    Abort  ${EndIf}  ${CanWriteToInstallDir} $R9  ${If} $R9 == "false"    MessageBox MB_OK "$(WARN_WRITE_ACCESS)"    Abort  ${EndIf}FunctionEndFunction preShortcuts  Call CheckCustom  !insertmacro MUI_HEADER_TEXT "$(SHORTCUTS_PAGE_TITLE)" "$(SHORTCUTS_PAGE_SUBTITLE)"  !insertmacro MUI_INSTALLOPTIONS_DISPLAY "shortcuts.ini"FunctionEndFunction leaveShortcuts  ${MUI_INSTALLOPTIONS_READ} $0 "shortcuts.ini" "Settings" "State"  ${If} $0 != 0    Abort  ${EndIf}  ${MUI_INSTALLOPTIONS_READ} $AddDesktopSC "shortcuts.ini" "Field 2" "State"  ${MUI_INSTALLOPTIONS_READ} $AddStartMenuSC "shortcuts.ini" "Field 3" "State"  ${MUI_INSTALLOPTIONS_READ} $AddQuickLaunchSC "shortcuts.ini" "Field 4" "State"FunctionEndFunction preStartMenu  Call CheckCustom  ${If} $AddStartMenuSC != 1    Abort  ${EndIf}FunctionEndFunction leaveInstFiles  FileClose $fhUninstallLog  ; Diff and add missing entries from the previous file log if it exists  ${If} ${FileExists} "$INSTDIR\uninstall\uninstall.bak"    SetDetailsPrint textonly    DetailPrint $(STATUS_CLEANUP)    SetDetailsPrint none    ${LogHeader} "Updating Uninstall Log With Previous Uninstall Log"    StrCpy $R0 "$INSTDIR\uninstall\uninstall.log"    StrCpy $R1 "$INSTDIR\uninstall\uninstall.bak"    GetTempFileName $R2    FileOpen $R3 $R2 w    ${TextCompareNoDetails} "$R1" "$R0" "SlowDiff" "GetDiff"    FileClose $R3    ${Unless} ${Errors}      ${FileJoin} "$INSTDIR\uninstall\uninstall.log" "$R2" "$INSTDIR\uninstall\uninstall.log"    ${EndUnless}    ${DeleteFile} "$INSTDIR\uninstall\uninstall.bak"    ${DeleteFile} "$R2"  ${EndIf}  Call WriteLogSeparator  ${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6  FileWrite $fhInstallLog "${BrandFullName} Installation Finished: $2-$1-$0 $4:$5:$6$\r$\n"  FileClose $fhInstallLogFunctionEnd; When we add an optional action to the finish page the cancel button is; enabled. This disables it and leaves the finish button as the only choice.Function preFinish  !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "settings" "cancelenabled" "0"FunctionEnd################################################################################# Initialization FunctionsFunction .onInit  ${GetParameters} $R0  ${If} $R0 != ""    ClearErrors    ${GetOptions} "$R0" "-ms" $R1    ${If} ${Errors}      ; Default install type      StrCpy $InstallType "1"      ; Support for specifying an installation configuration file.      ClearErrors      ${GetOptions} "$R0" "/INI=" $R1      ${Unless} ${Errors}        ; The configuration file must also exist        ${If} ${FileExists} "$R1"          SetSilent silent          ReadINIStr $0 $R1 "Install" "InstallDirectoryName"          ${If} $0 != ""            StrCpy $INSTDIR "$PROGRAMFILES\$0"          ${Else}            ReadINIStr $0 $R1 "Install" "InstallDirectoryPath"            ${If} $$0 != ""              StrCpy $INSTDIR "$0"            ${EndIf}          ${EndIf}          ${If} $INSTDIR == ""            ; Check if there is an existing uninstall registry entry for this            ; version of the application and if present install into that location            ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${BrandFullNameInternal} (${AppVersion})" "InstallLocation"            ${If} $0 == ""              StrCpy $INSTDIR "$PROGRAMFILES\${BrandFullName}"            ${Else}              GetFullPathName $INSTDIR "$0"              ${Unless} ${FileExists} "$INSTDIR"                StrCpy $INSTDIR "$PROGRAMFILES\${BrandFullName}"              ${EndUnless}            ${EndIf}          ${EndIf}          ; Quit if we are unable to create the installation directory or we are          ; unable to write to a file in the installation directory.          ClearErrors          ${If} ${FileExists} "$INSTDIR"            GetTempFileName $R2 "$INSTDIR"            FileOpen $R3 $R2 w            FileWrite $R3 "Write Access Test"            FileClose $R3            Delete $R2            ${If} ${Errors}              Quit            ${EndIf}          ${Else}            CreateDirectory "$INSTDIR"            ${If} ${Errors}              Quit            ${EndIf}          ${EndIf}          ReadINIStr $0 $R1 "Install" "CloseAppNoPrompt"          ${If} $0 == "true"            ClearErrors            ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"              ${DeleteFile} "$INSTDIR\${FileMainEXE}"            ${EndIf}            ${If} ${Errors}              ClearErrors              ${CloseApp} "false" ""              ${DeleteFile} "$INSTDIR\${FileMainEXE}"            ${EndIf}          ${EndIf}          ReadINIStr $0 $R1 "Install" "QuickLaunchShortcut"          ${If} $0 == "false"            StrCpy $AddQuickLaunchSC "0"          ${Else}            StrCpy $AddQuickLaunchSC "1"          ${EndIf}          ReadINIStr $0 $R1 "Install" "DesktopShortcut"          ${If} $0 == "false"            StrCpy $AddDesktopSC "0"          ${Else}            StrCpy $AddDesktopSC "1"          ${EndIf}          ReadINIStr $0 $R1 "Install" "StartMenuShortcuts"          ${If} $0 == "false"            StrCpy $AddStartMenuSC "0"          ${Else}            StrCpy $AddStartMenuSC "1"          ${EndIf}          ReadINIStr $0 $R1 "Install" "StartMenuDirectoryName"          ${If} $0 != ""            StrCpy $StartMenuDir "$0"          ${EndIf}        ${EndIf}      ${EndUnless}    ${Else}      ; Support for the deprecated -ms command line argument. The new command      ; line arguments are not supported when -ms is used.      SetSilent silent    ${EndIf}  ${EndIf}  ClearErrors  StrCpy $LANGUAGE 0  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "options.ini"  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "components.ini"  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "shortcuts.ini"  !insertmacro createBasicCustomOptionsINI  !insertmacro createComponentsINI  !insertmacro createShortcutsINI  ; There must always be nonlocalized and localized directories.  ${GetSize} "$EXEDIR\nonlocalized\" "/S=0K" $1 $8 $9  ${GetSize} "$EXEDIR\localized\" "/S=0K" $2 $8 $9  IntOp $0 $1 + $2  SectionSetSize 0 $0  ${If} ${FileExists} "$EXEDIR\optional\extensions\inspector@mozilla.org"    ; Set the section size for DOMi.    ${GetSize} "$EXEDIR\optional\extensions\inspector@mozilla.org" "/S=0K" $0 $8 $9    SectionSetSize 1 $0  ${Else}    ; Hide DOMi in the components page if it isn't available.    SectionSetText 1 ""  ${EndIf}  ; Set the section size for Talkback only if it exists.  ${If} ${FileExists} "$EXEDIR\optional\extensions\talkback@mozilla.org"    ${GetSize} "$EXEDIR\optional\extensions\talkback@mozilla.org" "/S=0K" $0 $8 $9    SectionSetSize 2 $0    ; Install Talkback by default.    SectionSetFlags 2 1  ${Else}    ; Hide Talkback in the components page if it isn't available.    SectionSetText 2 ""  ${EndIf}FunctionEnd

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -