📄 filezilla.nsi
字号:
StrCpy $0 "source"
goto source_end
source_failure:
StrCpy $0 ""
source_end:
Pop $2
Pop $1
SectionEnd
Section $(SecStartMenuName) SecStartMenu
SectionIn 1 2
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\FileZilla.lnk" "$INSTDIR\FileZilla.exe" "" "$INSTDIR\FileZilla.exe" 0
StrCmp $0 "source" "" +2
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\FileZilla Source Project.lnk" "$INSTDIR\source\FileZilla.dsw" "" "$INSTDIR\source\FileZilla.dsw" 0
StrCmp $1 "documentation" "" +2
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\FileZilla Documentation.lnk" "$INSTDIR\FileZilla.chm" "" "$INSTDIR\FileZilla.chm" 0
StrCmp $2 "french_documentation" "" +2
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\FileZilla Documentation (French).lnk" "$INSTDIR\FileZillaFrench.chm" "" "$INSTDIR\FileZillaFrench.chm" 0
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
Section $(SecDesktopIconName) SecDesktopIcon
SectionIn 1 2
CreateShortCut "$DESKTOP\FileZilla.lnk" "$INSTDIR\FileZilla.exe" "" "$INSTDIR\FileZilla.exe" 0
SectionEnd
Section $(SecDebugName) SecDebug
SectionIn 1 2
SetOutPath $INSTDIR
File ..\release\FIleZilla.pdb
SectionEnd
;--------------------------------
;Installer Functions
Function .onInit
;Language selection
!insertmacro MUI_LANGDLL_DISPLAY
;Init InstallOptions
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "download.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "settings.ini"
push $R0
StrCmp $LANGUAGE ${LANG_FRENCH} "" skip_preselect_french
!insertmacro SelectSection ${SecFrenchDocumentation}
skip_preselect_french:
pop $R0
FunctionEnd
Function DownloadOptions
StrCpy $R1 ""
SectionGetFlags ${SecFrenchDocumentation} $R0
Intop $R0 $R0 & "0x1"
StrCmp $R0 0 +5
StrCmp $R1 "" +2
StrCpy $R1 "$R1, "
StrCpy $R0 $(SecFrenchDocumentationName)
StrCpy $R1 "$R1$R0"
SectionGetFlags ${SecSourceCode} $R0
Intop $R0 $R0 & "0x1"
StrCmp $R0 0 +5
StrCmp $R1 "" +2
StrCpy $R1 "$R1, "
StrCpy $R0 $(SecSourceCodeName)
StrCpy $R1 "$R1$R0"
StrCmp $R1 "" "" +2
Return
!insertmacro MUI_HEADER_TEXT $(PageDownloadTitle) $(PageDownloadSubTitle)
!insertmacro MUI_INSTALLOPTIONS_WRITE "download.ini" "Field 1" text $(DownloadDialog1)
!insertmacro MUI_INSTALLOPTIONS_WRITE "download.ini" "Field 3" text $(DownloadDialog3)
!insertmacro MUI_INSTALLOPTIONS_WRITE "download.ini" "Field 4" text $(DownloadDialog4)
!insertmacro MUI_INSTALLOPTIONS_WRITE "download.ini" "Field 5" text $(DownloadDialog5)
!insertmacro MUI_INSTALLOPTIONS_WRITE "download.ini" "Field 6" text $(DownloadDialog6)
!insertmacro MUI_INSTALLOPTIONS_WRITE "download.ini" "Field 8" text $(DownloadDialog8)
!insertmacro MUI_INSTALLOPTIONS_WRITE "download.ini" "Field 2" text $R1
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "download.ini"
Pop $IO_HWND
!insertmacro MUI_INSTALLOPTIONS_SHOW
FunctionEnd
Function DownloadOptionsEnd
; At this point the user has either pressed Next or one of our custom buttons
; We find out which by reading from the INI file
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "download.ini" "Settings" "State"
StrCmp $R0 0 validate_dldialog ; Next button?
StrCmp $R0 4 onchange_dldialog
StrCmp $R0 5 onchange_dldialog
StrCmp $R0 6 onchange_dldialog
Abort ; Return to the page
onchange_dldialog:
; Check state of the packagedir checkbox and DirRequest fields
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "download.ini" "Field 4" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "download.ini" "Field 6" "State"
GetDlgItem $R2 $IO_HWND 1205 ; Use package directory checkbox
GetDlgItem $R3 $IO_HWND 1206 ; Package directory input field
GetDlgItem $R4 $IO_HWND 1207 ; Package directory browse button
EnableWindow $R2 $R0
StrCmp $R0 0 +4
EnableWindow $R3 $R1
EnableWindow $R4 $R1
goto +3
EnableWindow $R3 0
EnableWindow $R4 0
Abort ; Return to the page
validate_dldialog:
; Nothing to validate
FunctionEnd
Function Settings
StrCpy $R1 ""
SectionGetFlags ${SecFrenchDocumentation} $R0
Intop $R0 $R0 & "0x1"
StrCmp $R0 0 +2
StrCpy $R1 "x"
SectionGetFlags ${SecSourceCode} $R0
Intop $R0 $R0 & "0x1"
StrCmp $R0 0 +2
StrCpy $R1 "x"
StrCpy $R0 ""
StrCmp $R1 "" "" skipsetinstallbutton
strCpy $R0 $(^InstallBtn)
skipsetinstallbutton:
!insertmacro MUI_INSTALLOPTIONS_WRITE "settings.ini" settings NextButtonText $R0
!insertmacro MUI_INSTALLOPTIONS_WRITE "settings.ini" "Field 1" text $(QuestionRunInSecureMode)
!insertmacro MUI_INSTALLOPTIONS_WRITE "settings.ini" "Field 2" text $(UseSecureMode)
!insertmacro MUI_INSTALLOPTIONS_WRITE "settings.ini" "Field 3" text $(DontUseSecureMode)
ReadRegStr $R0 HKCU Software\FileZilla "Run in Secure mode"
StrCmp $R0 "1" preselectsecure
ReadRegStr $R0 HKLM Software\FileZilla "Run in Secure mode"
StrCmp $R0 "1" preselectsecure
goto preselectsecure_end
preselectsecure:
!insertmacro MUI_INSTALLOPTIONS_WRITE "settings.ini" "Field 2" state 1
!insertmacro MUI_INSTALLOPTIONS_WRITE "settings.ini" "Field 3" state 0
preselectsecure_end:
!insertmacro MUI_INSTALLOPTIONS_WRITE "settings.ini" "Field 4" text $(StorageQuestion)
!insertmacro MUI_INSTALLOPTIONS_WRITE "settings.ini" "Field 5" text $(UseXML)
!insertmacro MUI_INSTALLOPTIONS_WRITE "settings.ini" "Field 6" text $(UseRegistry)
!insertmacro MUI_INSTALLOPTIONS_WRITE "settings.ini" "Field 7" text $(ForceUseRegistry)
ReadRegStr $R0 HKCU Software\FileZilla "Use Registry"
StrCmp $R0 "2" preselectstorage_force
StrCmp $R0 "1" preselectstorage
ReadRegStr $R0 HKLM Software\FileZilla "Use Registry"
StrCmp $R0 "2" preselectstorage_force
StrCmp $R0 "1" preselectstorage
!insertmacro MUI_INSTALLOPTIONS_WRITE "settings.ini" "Field 7" flags "DISABLED"
goto preselectstorage_end
preselectstorage_force:
!insertmacro MUI_INSTALLOPTIONS_WRITE "settings.ini" "Field 7" state 1
preselectstorage:
!insertmacro MUI_INSTALLOPTIONS_WRITE "settings.ini" "Field 6" state 1
!insertmacro MUI_INSTALLOPTIONS_WRITE "settings.ini" "Field 5" state 0
preselectstorage_end:
!insertmacro MUI_HEADER_TEXT $(PageSettingsTitle) $(PageSettingsSubTitle)
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "settings.ini"
Pop $IO_HWND
!insertmacro MUI_INSTALLOPTIONS_SHOW
FunctionEnd
Function SettingsEnd
; At this point the user has either pressed Next or one of our custom buttons
; We find out which by reading from the INI file
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "settings.ini" "Settings" "State"
StrCmp $R0 0 validate_settingsdialog ; Next button?
StrCmp $R0 5 onchange_settingsdialog
StrCmp $R0 6 onchange_settingsdialog
Abort ; Return to the page
onchange_settingsdialog:
; Make the Force registry field depend on use registry radiobuttun
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "settings.ini" "Field 5" "State"
GetDlgItem $R1 $IO_HWND 1206 ; Force registry checkbox
StrCmp $R0 0 "" +3
EnableWindow $R1 1
goto +2
EnableWindow $R1 0
Abort ; Return to the page
validate_settingsdialog:
; Nothing to validate
FunctionEnd
!macro checklang RefLang LangToFind goto
push "${Reflang}"
push "${LangToFind}"
call StrStr
Pop $R1
StrCmp $1 "" "" ${goto}
!macroend
Function WriteLanguage
Push $R0
Push $R1
;Checks current language set in the registry, if none is set (or one not included in the installer) set it to the current one
StrCpy $R0 ""
;First check/set the value under HKCU
ReadRegStr $R0 HKCU Software\FileZilla Language
StrCmp $R0 "" HKCU_SetLanguage
!insertmacro checklang "$R0" "Bulgarian" HKCU_SetLanguage
!insertmacro checklang "$R0" "English" HKCU_SetLanguage
!insertmacro checklang "$R0" "Deutsch" HKCU_SetLanguage
!insertmacro checklang "$R0" "Fran鏰is" HKCU_SetLanguage
!insertmacro checklang "$R0" "Italiano" HKCU_SetLanguage
!insertmacro checklang "$R0" "Hungarian" HKCU_SetLanguage
!insertmacro checklang "$R0" "Polski" HKCU_SetLanguage
!insertmacro checklang "$R0" "Simplified Chinese" HKCU_SetLanguage
!insertmacro checklang "$R0" "Traditional Chinese" HKCU_SetLanguage
!insertmacro checklang "$R0" "Japanese" HKCU_SetLanguage
!insertmacro checklang "$R0" "Russian" HKCU_SetLanguage
goto HKLM_CheckLanguage
HKCU_SetLanguage:
WriteRegStr HKCU Software\FileZilla Language $(FZLanguageName)
HKLM_CheckLanguage:
StrCpy $R0 ""
;Now check/set the value under HKLM
ReadRegStr $R0 HKLM Software\FileZilla Language
StrCmp $R0 "" HKLM_SetLanguage
!insertmacro checklang "$R0" "Bulgarian" HKLM_SetLanguage
!insertmacro checklang "$R0" "English" HKLM_SetLanguage
!insertmacro checklang "$R0" "Deutsch" HKLM_SetLanguage
!insertmacro checklang "$R0" "Fran鏰is" HKLM_SetLanguage
!insertmacro checklang "$R0" "Italiano" HKLM_SetLanguage
!insertmacro checklang "$R0" "Hungarian" HKLM_SetLanguage
!insertmacro checklang "$R0" "Polski" HKLM_SetLanguage
!insertmacro checklang "$R0" "Simplified Chinese" HKLM_SetLanguage
!insertmacro checklang "$R0" "Traditional Chinese" HKLM_SetLanguage
!insertmacro checklang "$R0" "Japanese" HKLM_SetLanguage
!insertmacro checklang "$R0" "Russian" HKLM_SetLanguage
goto SetLanguageDone
HKLM_SetLanguage:
WriteRegStr HKLM Software\FileZilla Language $(FZLanguageName)
SetLanguageDone:
Pop $R1
Pop $R0
FunctionEnd
; GetParameters
; input, none
; output, top of stack (replaces, with e.g. whatever)
; modifies no other variables.
Function GetParameters
Push $R0
Push $R1
Push $R2
Push $R3
StrCpy $R2 1
StrLen $R3 $CMDLINE
;Check for quote or space
StrCpy $R0 $CMDLINE $R2
StrCmp $R0 '"' 0 +3
StrCpy $R1 '"'
Goto loop
StrCpy $R1 " "
loop:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 $R1 get
StrCmp $R2 $R3 get
Goto loop
get:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 " " get
StrCpy $R0 $CMDLINE "" $R2
Pop $R3
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -