📄 kceasy.nsi
字号:
;------------------------------------------------------------------------------------------
; This file creates the KCeasy installer including giFT and plugins
;------------------------------------------------------------------------------------------
; Compile time options
;------------------------------------------------------------------------------------------
!define APP_NAME "KCeasy"
!define APP_NAME_SMALL "kceasy"
!define APP_WEBSITE "http://www.kceasy.com"
!define VERSION "0.19"
!define USE_OPENFT
!define USE_GNUTELLA
#!define USE_FASTTRACK
!define USE_ARES
!define USE_VLC
#!define DEBUG
!define RELEASE_CANDIDATE 1
!ifndef BUILD_ROOT
!define BUILD_ROOT "..\.."
!endif
!ifndef DIST_DIR
!define DIST_DIR "${BUILD_ROOT}\dist"
!endif
!ifndef BRAND_DIR
!define BRAND_DIR "${BUILD_ROOT}\brand\${APP_NAME}"
!endif
!ifdef DEBUG
!define D "d"
!define _D "_d"
!else
!define D ""
!define _D ""
!endif
!ifdef RELEASE_CANDIDATE
!define OUTFILE "${APP_NAME_SMALL}-${VERSION}-rc${RELEASE_CANDIDATE}-setup.exe"
!define KCEASY_DESC "${APP_NAME} ${VERSION}-rc${RELEASE_CANDIDATE}"
!else
!define OUTFILE "${APP_NAME_SMALL}-${VERSION}-setup.exe"
!define KCEASY_DESC "${APP_NAME} ${VERSION}"
!endif
!include "MUI.nsh"
!addplugindir "${BUILD_ROOT}\nsis"
; Installer options
;------------------------------------------------------------------------------------------
Name "${APP_NAME}"
Caption "${KCEASY_DESC} Setup"
OutFile "${OUTFILE}"
InstallDir "$PROGRAMFILES\${APP_NAME}"
InstallDirRegKey HKEY_LOCAL_MACHINE "Software\${APP_NAME}" "InstallPath"
;LogSet On
SetCompressor lzma
SetPluginUnload alwaysoff
SetOverwrite on
ShowInstDetails hide
ShowUninstDetails hide
FileErrorText "Error writing file$\r$\n$0$\r$\n$\r$\nPlease make sure ${APP_NAME} is not \
running and then try to install again.$\r$\nIf the problem persists try \
installing again after rebooting your PC."
InstType "Full (${APP_NAME}, giFT and all plugins)"
;InstType "Lite (${APP_NAME} only)"
; Modern UI config
;------------------------------------------------------------------------------------------
!define MUI_UNINSTALLER
!define MUI_ICON "res\kceasy.ico"
!define MUI_UNICON "res\kceasy_uninstall.ico"
!define MUI_WELCOMEFINISHPAGE_BITMAP "res\logo_installer.bmp"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "res\logo_installer.bmp"
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_ABORTWARNING
!define MUI_UNABORTWARNING
; !define MUI_FINISHPAGE_NOREBOOTSUPPORT
!define MUI_FINISHPAGE_RUN "$INSTDIR\${APP_NAME}.exe"
!define MUI_CUSTOMFUNCTION_GUIINIT ShutdownKCeasy
!define MUI_CUSTOMFUNCTION_UNGUIINIT un.ShutdownKCeasy
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
; Languages
;------------------------------------------------------------------------------------------
!insertmacro MUI_LANGUAGE "English"
; Language strings
;------------------------------------------------------------------------------------------
LangString DESC_SEC_KCEASY ${LANG_ENGLISH} "Installs the ${APP_NAME} binary (required)."
LangString DESC_SEC_GIFT ${LANG_ENGLISH} "Installs giFT including OpenFT, Gnutella and Ares plugins (required)."
LangString DESC_SEC_STARTMENU ${LANG_ENGLISH} "Adds ${APP_NAME} to the Start menu."
LangString DESC_SEC_DESKTOP ${LANG_ENGLISH} "Adds icons for ${APP_NAME} and My Shared Folder to the Desktop."
LangString DESC_SEC_QUICKLAUNCH ${LANG_ENGLISH} "Adds ${APP_NAME} icon to the QuickLaunch area."
LangString DESC_SEC_STARTUP ${LANG_ENGLISH} "Starts ${APP_NAME} everytime you boot your computer."
; helper functions and macros
;------------------------------------------------------------------------------------------
;--- Written by KiCHiK ---
; Push "C:\program files\geoffrey\files"
; Call GetFileName
; Pop $R0 ; now "files"
Function GetFileName
Exch $0 ; input string
Push $1
Push $2
StrCpy $1 0
loop:
IntOp $1 $1 - 1
StrCpy $2 $0 1 $1
StrCmp $2 "" exit2
StrCmp $2 "\" exit1 ; replace "\" with "." if you want file extension
Goto loop
exit1:
IntOp $1 $1 + 1
StrCpy $0 $0 "" $1
exit2:
Pop $2
Pop $1
Exch $0
FunctionEnd
!macro MCopyConfPreserve SRC_PATH DST_DIR EXCLUDE
Push ${SRC_PATH}
Call GetFileName
Pop $R0 ; filename
IfFileExists "${DST_DIR}\$R0" 0 "NoOldConf_${SRC_PATH}"
CopyFiles /SILENT /FILESONLY "${DST_DIR}\$R0" $PLUGINSDIR
NoOldConf_${SRC_PATH}:
SetOutPath ${DST_DIR}
File ${SRC_PATH}
KCeasyExt::CopyINIValuesExcept "$PLUGINSDIR\$R0" "${DST_DIR}\$R0" "${EXCLUDE}"
ClearErrors
!macroend
; this dll is needed by libdb
Function CheckForMSVCP60
ClearErrors
SearchPath $R0 "msvcp60.dll"
IfErrors 0 DllExists
; Only show message box if we are not in silent install mode
KCeasyExt::CmdLineContains "/S"
StrCmp $R0 "found" DllExists
MessageBox MB_OK|MB_SETFOREGROUND|MB_ICONEXCLAMATION "The file msvcp60.dll is missing from your computer.$\r$\nThis file is required to run ${APP_NAME} please download it from http://www.kceasy.com/download/."
DllExists:
FunctionEnd
; Event handlers
;------------------------------------------------------------------------------------------
Function ShutdownKCeasy
; if auto updating sleep a few milliseconds
KCeasyExt::CmdLineContains "/autoupdate"
StrCmp $R0 "not_found" NotAutoUpdating
Sleep 200
NotAutoUpdating:
; check if KCeasy is running
KCeasyExt::IsKCeasyRunning
StrCmp $R0 "not_running" KCeasyNotRunning
; ask the user
; Only show message box if we are not in silent install mode
KCeasyExt::CmdLineContains "/S"
StrCmp $R0 "found" CloseKCeasy
MessageBox MB_OKCANCEL|MB_SETFOREGROUND|MB_ICONEXCLAMATION "Setup has detected that ${APP_NAME} is currently running.$\r$\nSetup will shutdown ${APP_NAME} now so it can be updated." IDOK CloseKCeasy
Abort ; exit installer
CloseKCeasy:
KCeasyExt::ShutdownKCeasy 3
KCeasyNotRunning:
FunctionEnd
Function un.ShutdownKCeasy
; check if KCeasy is running
KCeasyExt::IsKCeasyRunning
StrCmp $R0 "not_running" KCeasyNotRunning
; ask the user
; Only show message box if we are not in silent install mode
KCeasyExt::CmdLineContains "/S"
StrCmp $R0 "found" CloseKCeasy
MessageBox MB_OKCANCEL|MB_SETFOREGROUND|MB_ICONEXCLAMATION "Setup has detected that ${APP_NAME} is currently running.$\r$\nSetup will shutdown ${APP_NAME} now so it can be removed." IDOK CloseKCeasy
Abort ; exit installer
CloseKCeasy:
KCeasyExt::ShutdownKCeasy 3
KCeasyNotRunning:
FunctionEnd
Function .onInit
InitPluginsDir
FunctionEnd
; Installer Sections
;------------------------------------------------------------------------------------------
Section "!${APP_NAME} (required)" SEC_KCEASY
SectionIn 1 2 RO
; install KCeasy
SetOutPath $INSTDIR
File /oname=$OUTDIR\${APP_NAME}.exe ${DIST_DIR}\KCeasy_p.exe
; File ${BRAND_DIR}\${APP_NAME}.exe.manifest
File ${BRAND_DIR}\License.txt
File ${BRAND_DIR}\Readme.txt
File ${BUILD_ROOT}\ChangeLog.txt
File ${BUILD_ROOT}\tcpip_patcher\tcpip_patcher.sys
; copy config, keeping old values
!insertmacro MCopyConfPreserve "${BRAND_DIR}\${APP_NAME_SMALL}.conf" "$INSTDIR" \
"gui/update_last_check"
; copy bookmarks.conf if it does not exist
IfFileExists "$INSTDIR\Bookmarks.conf" NoBookmarksConf
File ${BRAND_DIR}\Bookmarks.conf
NoBookmarksConf:
; copy banlists.conf if it does not exist
IfFileExists "$INSTDIR\Banlists.conf" NoBanlistsConf
File ${BRAND_DIR}\Banlists.conf
NoBanlistsConf:
; Add localization files
File /r ${DIST_DIR}\locale
!ifdef USE_VLC
; install vlc
SetOutPath $INSTDIR
File ${DIST_DIR}\simplevlc.dll
; remove old plugin dlls since we now have everything in simplevlc.dll
Delete $INSTDIR\vlcplugins\*.dll
RMDir /r $INSTDIR\vlcplugins
; set use of player in config
WriteINIStr $INSTDIR\${APP_NAME_SMALL}.conf player always_use_external "0"
!endif ; USE_VLC
; install uninstaller
WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "DisplayName" "${KCEASY_DESC}"
WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "DisplayIcon" '"$INSTDIR\uninstall.exe"'
WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "HelpLink" "${APP_WEBSITE}"
WriteUninstaller "uninstall.exe"
; Registering install path, so future installs will use the same path
WriteRegStr HKEY_LOCAL_MACHINE "Software\${APP_NAME}" "InstallPath" $INSTDIR
; If we were run by auto update, remove installer on next reboot
KCeasyExt::CmdLineContains "/autoupdate"
StrCmp $R0 "not_found" NotAutoUpdating
System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
IfRebootFlag RebootFlagAlreadySet
Delete /REBOOTOK $R0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -