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

📄 kceasy.nsi

📁 Last change: 2008-02-03 This is the source code of KCeasy。
💻 NSI
📖 第 1 页 / 共 2 页
字号:
	SetRebootFlag false    ; reboot flag was not set, don't set it because this failed
	Goto NotAutoUpdating
RebootFlagAlreadySet:
	Delete /REBOOTOK $R0
NotAutoUpdating:

SectionEnd


Var InstalledNetworks
Section "!giFT and network plugins (required)" SEC_GIFT
	SectionIn 1
	StrCpy $InstalledNetworks ""

	; install giFT

	SetOutPath $INSTDIR\giFT\data
	File ${DIST_DIR}\giFT\data\mime.types

	; copy config, keeping old values
	!insertmacro MCopyConfPreserve "${DIST_DIR}\giFT\conf\giftd.conf" \
	                               "$INSTDIR\giFT\conf" ""

	SetOutPath $INSTDIR\giFT
	File ${DIST_DIR}\giFT\giFT${D}.dll
	File ${DIST_DIR}\giFT\giFTl.exe
	File ${DIST_DIR}\giFT\libgiFT${D}.dll
	File ${DIST_DIR}\giFT\libgiFTproto${D}.dll
	File ${DIST_DIR}\giFT\zlib.dll
	File ${DIST_DIR}\giFT\libdb41${D}.dll
	File ${DIST_DIR}\giFT\ogg${_D}.dll
	File ${DIST_DIR}\giFT\vorbis${_D}.dll
	File ${DIST_DIR}\giFT\vorbisfile${_D}.dll
!ifdef DEBUG
	File ${DIST_DIR}\giFT\msvcrtd.dll
	File ${DIST_DIR}\giFT\msvcp60d.dll
!endif

	CreateDirectory "$INSTDIR\giFT\incoming"
	CreateDirectory "$INSTDIR\My Shared Folder"

	; get installer filename in $R0
	System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
	; copy the installer into 'My Shared folder' if not already there
	IfFileExists "$INSTDIR\My Shared Folder\${OUTFILE}" InstallerAlreadyShared
	CopyFiles /SILENT /FILESONLY $R0 "$INSTDIR\My Shared Folder\${OUTFILE}" 2480
InstallerAlreadyShared:

	; add gift to WinXP SP2 firewall exception list
	KCeasyExt::AddFirewallException "$INSTDIR\giFT\giFTl.exe" "giFT Loader for KCeasy"

	; install plugins

!ifdef USE_OPENFT
	SetOutPath $INSTDIR\giFT\conf\OpenFT
	; install nodes file only if not present
	IfFileExists "$INSTDIR\giFT\conf\OpenFT\nodes" HasOpenFTNodes
	File ${DIST_DIR}\giFT\conf\OpenFT\nodes
HasOpenFTNodes:
	SetOutPath $INSTDIR\giFT\plugins
	File ${DIST_DIR}\giFT\plugins\OpenFT.dll
	; copy config, keeping old values
	!insertmacro MCopyConfPreserve "${DIST_DIR}\giFT\conf\OpenFT\OpenFT.conf" \
	                               "$INSTDIR\giFT\conf\OpenFT" ""
	; check for dll needed by libdb
	call CheckForMSVCP60
	; add this network to giftd.conf below
	StrCpy $InstalledNetworks "$InstalledNetworks:OpenFT"
!endif

!ifdef USE_GNUTELLA
	SetOutPath $INSTDIR\giFT\conf\Gnutella
	; install nodes file only if not present
	IfFileExists "$INSTDIR\giFT\conf\Gnutella\nodes" HasGnutellaNodes
	File ${DIST_DIR}\giFT\conf\Gnutella\nodes
HasGnutellaNodes:
	File ${DIST_DIR}\giFT\conf\Gnutella\gwebcaches
	File ${DIST_DIR}\giFT\conf\Gnutella\hostiles.txt
	SetOutPath $INSTDIR\giFT\plugins
	File ${DIST_DIR}\giFT\plugins\Gnutella.dll
	SetOutPath $INSTDIR\giFT
	File ${DIST_DIR}\giFT\libxml2.dll
	; copy config, keeping old values
	!insertmacro MCopyConfPreserve "${DIST_DIR}\giFT\conf\Gnutella\Gnutella.conf" \
	                               "$INSTDIR\giFT\conf\Gnutella" ""
	; add this network to giftd.conf below
	StrCpy $InstalledNetworks "$InstalledNetworks:Gnutella"
!endif

!ifdef USE_FASTTRACK
	SetOutPath $INSTDIR\giFT\conf\FastTrack
	; install nodes file only if not present
	IfFileExists "$INSTDIR\giFT\conf\FastTrack\nodes" HasFastTrackNodes
	File ${DIST_DIR}\giFT\conf\FastTrack\nodes
HasFastTrackNodes:
	File ${DIST_DIR}\giFT\conf\FastTrack\banlist
	SetOutPath $INSTDIR\giFT\plugins
	File ${DIST_DIR}\giFT\plugins\FastTrack.dll
	; copy config, keeping old values
	!insertmacro MCopyConfPreserve "${DIST_DIR}\giFT\conf\FastTrack\FastTrack.conf" \
	                               "$INSTDIR\giFT\conf\FastTrack" ""
	; add this network to giftd.conf below
	StrCpy $InstalledNetworks "$InstalledNetworks:FastTrack"
!endif

!ifdef USE_ARES
	SetOutPath $INSTDIR\giFT\conf\Ares
	; install nodes file only if not present
	IfFileExists "$INSTDIR\giFT\conf\Ares\nodes" HasAresNodes
	File ${DIST_DIR}\giFT\conf\Ares\nodes
HasAresNodes:
	SetOutPath $INSTDIR\giFT\plugins
	File ${DIST_DIR}\giFT\plugins\Ares.dll
	; copy config, keeping old values
	!insertmacro MCopyConfPreserve "${DIST_DIR}\giFT\conf\Ares\Ares.conf" \
	                               "$INSTDIR\giFT\conf\Ares" ""
	; add this network to giftd.conf below
	StrCpy $InstalledNetworks "$InstalledNetworks:Ares"
!endif

	; Make sure installed plugins are actually activated
	KCeasyExt::AddPlugins "$INSTDIR\giFT\conf\giftd.conf" $InstalledNetworks
SectionEnd


Section "Add ${APP_NAME} to Start menu" SEC_STARTMENU
	SectionIn 1 2
	SetShellVarContext current
	CreateDirectory "$SMPROGRAMS\${APP_NAME}"

	SetOutPath $INSTDIR  ; working directory for shortcuts
	CreateShortCut "$SMPROGRAMS\${APP_NAME}\${APP_NAME}.lnk" "$INSTDIR\${APP_NAME}.exe" "" "$INSTDIR\${APP_NAME}.exe" 0
	WriteINIStr    "$SMPROGRAMS\${APP_NAME}\${APP_NAME} Home Page.url" "InternetShortcut" "URL" ${APP_WEBSITE}
	CreateShortCut "$SMPROGRAMS\${APP_NAME}\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"

	; create "my shared folder" shortcut if giFT is installed
	SectionGetFlags ${SEC_GIFT} $R0
	IntOp $R0 $R0 & 1   ; bit one is set when section selected
	IntCmpU $R0 0 NoGift
	CreateShortCut "$SMPROGRAMS\${APP_NAME}\${APP_NAME} Shared Folder.lnk" "$INSTDIR\My Shared Folder" "" "$INSTDIR\${APP_NAME}.exe" 2
NoGift:
SectionEnd


Section "Add ${APP_NAME} to Desktop" SEC_DESKTOP
	SectionIn 1 2
	SetShellVarContext current
	SetOutPath $INSTDIR  ; working directory for shortcuts
	; create kceasy shortcut
	CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${APP_NAME}.exe" "" "$INSTDIR\${APP_NAME}.exe" 0
	; create "my shared folder" shortcut if giFT is installed
	SectionGetFlags ${SEC_GIFT} $R0
	IntOp $R0 $R0 & 1   ; bit one is set when section selected
	IntCmpU $R0 0 NoGift
	CreateShortCut "$DESKTOP\${APP_NAME} Shared Folder.lnk" "$INSTDIR\My Shared Folder" "" "$INSTDIR\${APP_NAME}.exe" 2
NoGift:
SectionEnd


Section "Add ${APP_NAME} to QuickLaunch Folder" SEC_QUICKLAUNCH
	SectionIn 1 2
	SetShellVarContext current
	SetOutPath $INSTDIR  ; working directory for shortcuts
	StrCmp $QUICKLAUNCH "" NoQuicklaunch
	CreateShortCut "$QUICKLAUNCH\${APP_NAME}.lnk" "$INSTDIR\${APP_NAME}.exe" "" "$INSTDIR\${APP_NAME}.exe" 0
NoQuicklaunch:
SectionEnd


Section "Run ${APP_NAME} on startup" SEC_STARTUP
	SectionIn 1
	; KCeasy will update the registry to reflect this
	WriteINIStr $INSTDIR\${APP_NAME_SMALL}.conf gui run_on_startup "1"
SectionEnd


; Section descriptions
;------------------------------------------------------------------------------------------

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_KCEASY}      $(DESC_SEC_KCEASY)
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_GIFT}        $(DESC_SEC_GIFT)
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_STARTMENU}   $(DESC_SEC_STARTMENU)
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_DESKTOP}     $(DESC_SEC_DESKTOP)
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_QUICKLAUNCH} $(DESC_SEC_QUICKLAUNCH)
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC_STARTUP}     $(DESC_SEC_STARTUP)
!insertmacro MUI_FUNCTION_DESCRIPTION_END

Function .onSelChange
    ; warn user if he tries to install without gift
	SectionGetFlags ${SEC_GIFT} $R0
	IntOp $R0 $R0 & 1   ; bit one is set when section selected
	IntCmpU $R0 1 GiftSelected
    ; Only show message box if we are not in silent install mode
    KCeasyExt::CmdLineContains "/S"
    StrCmp $R0 "found" GiftSelected
	MessageBox MB_OK|MB_SETFOREGROUND|MB_ICONEXCLAMATION "You have chosen to not install giFT.$\r$\n${APP_NAME} will be useless without giFT. It is strongly recommended you install it!"
GiftSelected:
FunctionEnd

; Uninstaller Section
;------------------------------------------------------------------------------------------

Section Uninstall

	DeleteRegValue HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "UninstallString"
	DeleteRegValue HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "DisplayName"
	DeleteRegKey HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"

	DeleteRegKey HKEY_LOCAL_MACHINE "Software\${APP_NAME}"

	; remove plugins

!ifdef USE_OPENFT
	RMDir /r $INSTDIR\giFT\conf\OpenFT\db
	RMDir /r $INSTDIR\giFT\conf\OpenFT
	Delete $INSTDIR\giFT\plugins\OpenFT.dll
!endif

!ifdef USE_GNUTELLA
	RMDir /r $INSTDIR\giFT\conf\Gnutella
	Delete $INSTDIR\giFT\plugins\Gnutella.dll
!endif

!ifdef USE_FASTTRACK
	RMDir /r $INSTDIR\giFT\conf\FastTrack
	Delete $INSTDIR\giFT\plugins\FastTrack.dll
!endif

!ifdef USE_ARES
	RMDir /r $INSTDIR\giFT\conf\Ares
	Delete $INSTDIR\giFT\plugins\Ares.dll
!endif

	; remove gift from WinXP SP2 firewall exception list
	KCeasyExt::RemoveFirewallException "$INSTDIR\giFT\giFTl.exe"

	; remove giFT

	RMDir /r $INSTDIR\giFT\data
	RMDir /r $INSTDIR\giFT\conf
	RMDir /r $INSTDIR\giFT\plugins
	Delete $INSTDIR\giFT\*.*

	; ask user if he wants to remove incomplete downloads
	FindFirst $0 $1 $INSTDIR\giFT\incoming\*.state
	StrCmp $1 "" NoIncompleteFiles
	FindClose $0

	MessageBox MB_YESNO|MB_SETFOREGROUND|MB_ICONEXCLAMATION "You have incomplete downloads in ${APP_NAME}.$\r$\nDo you want to permanently delete them?" /SD IDYES IDNO KeepIncompleteFiles
	
NoIncompleteFiles:
	RMDir /r $INSTDIR\giFT

KeepIncompleteFiles:

	; remove VLC

!ifdef USE_VLC
	RMDir /r $INSTDIR\vlcplugins
	Delete $INSTDIR\simplevlc.dll
!endif

	; remove KCeasy

	# make a good faith effort to remove our installers
	Delete "$INSTDIR\My Shared Folder\${APP_NAME_SMALL}-*-setup.exe"
	Delete "$INSTDIR\My Shared Folder\${APP_NAME_SMALL}-*-inst.exe"
	# only remove shared folder if it's empty
	RMDir "$INSTDIR\My Shared Folder"

	# remove locales
	RMDir /r $INSTDIR\locale

	Delete $INSTDIR\*.*
	RMDir $INSTDIR

	Delete "$SMPROGRAMS\${APP_NAME}\*.*"
	RMDir /r "$SMPROGRAMS\${APP_NAME}"

	Delete "$DESKTOP\${APP_NAME}.lnk"
	Delete "$DESKTOP\${APP_NAME} Shared Folder.lnk"
	Delete "$QUICKLAUNCH\${APP_NAME}.lnk"

	; remove run registry key
	DeleteRegValue HKEY_CURRENT_USER "Software\Microsoft\Windows\CurrentVersion\Run" "${APP_NAME}"

SectionEnd


⌨️ 快捷键说明

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