Windows tray app (#3103)
* Check if already running in ui command * Windows tray app * Upadted CI scripts
This commit is contained in:
committed by
Gav Wood
parent
7fb39d1511
commit
d101cb5247
@@ -1,10 +1,17 @@
|
||||
!include WinMessages.nsh
|
||||
|
||||
!define WND_CLASS "Parity"
|
||||
!define WND_TITLE "Parity"
|
||||
!define WAIT_MS 5000
|
||||
!define SYNC_TERM 0x00100001
|
||||
|
||||
!define APPNAME "Parity"
|
||||
!define COMPANYNAME "Ethcore"
|
||||
!define DESCRIPTION "Fast, light, robust Ethereum implementation"
|
||||
!define VERSIONMAJOR 1
|
||||
!define VERSIONMINOR 4
|
||||
!define VERSIONBUILD 0
|
||||
!define ARGS "--warp --mode=passive"
|
||||
|
||||
!addplugindir .\
|
||||
|
||||
@@ -13,6 +20,10 @@
|
||||
!define ABOUTURL "https://github.com/ethcore/parity" # "Publisher" link
|
||||
!define INSTALLSIZE 26120
|
||||
|
||||
!define termMsg "Installer cannot stop running ${WND_TITLE}.$\nDo you want to terminate process?"
|
||||
!define stopMsg "Stopping ${WND_TITLE} Application"
|
||||
|
||||
|
||||
RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on)
|
||||
|
||||
InstallDir "$PROGRAMFILES64\${COMPANYNAME}\${APPNAME}"
|
||||
@@ -26,7 +37,7 @@ outFile "installer.exe"
|
||||
|
||||
page license
|
||||
page directory
|
||||
Page instfiles
|
||||
page instfiles
|
||||
|
||||
!macro VerifyUserIsAdmin
|
||||
UserInfo::GetAccountType
|
||||
@@ -38,6 +49,31 @@ ${If} $0 != "admin" ;Require admin rights on NT4+
|
||||
${EndIf}
|
||||
!macroend
|
||||
|
||||
!macro TerminateApp
|
||||
Push $0 ; window handle
|
||||
Push $1
|
||||
Push $2 ; process handle
|
||||
DetailPrint "$(stopMsg)"
|
||||
FindWindow $0 '${WND_CLASS}' ''
|
||||
IntCmp $0 0 done
|
||||
System::Call 'user32.dll::GetWindowThreadProcessId(i r0, *i .r1) i .r2'
|
||||
System::Call 'kernel32.dll::OpenProcess(i ${SYNC_TERM}, i 0, i r1) i .r2'
|
||||
SendMessage $0 ${WM_CLOSE} 0 0 /TIMEOUT=${TO_MS}
|
||||
System::Call 'kernel32.dll::WaitForSingleObject(i r2, i ${WAIT_MS}) i .r1'
|
||||
IntCmp $1 0 close
|
||||
MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION "$(termMsg)" /SD IDYES IDYES terminate IDNO close
|
||||
System::Call 'kernel32.dll::CloseHandle(i r2) i .r1'
|
||||
Quit
|
||||
terminate:
|
||||
System::Call 'kernel32.dll::TerminateProcess(i r2, i 0) i .r1'
|
||||
close:
|
||||
System::Call 'kernel32.dll::CloseHandle(i r2) i .r1'
|
||||
done:
|
||||
Pop $2
|
||||
Pop $1
|
||||
Pop $0
|
||||
!macroend
|
||||
|
||||
function .onInit
|
||||
setShellVarContext all
|
||||
!insertmacro VerifyUserIsAdmin
|
||||
@@ -48,10 +84,13 @@ section "install"
|
||||
setOutPath $INSTDIR
|
||||
# Files added here should be removed by the uninstaller (see section "uninstall")
|
||||
file /oname=parity.exe ..\target\release\parity.exe
|
||||
file /oname=ptray.exe ..\windows\ptray\Release\ptray.exe
|
||||
|
||||
file "logo.ico"
|
||||
file vc_redist.x64.exe
|
||||
|
||||
ExecWait '"$INSTDIR\vc_redist.x64.exe" /passive /norestart'
|
||||
delete $INSTDIR\vc_redist.x64.exe
|
||||
# Add any other files for the install directory (license files, app data, etc) here
|
||||
|
||||
# Uninstaller - See function un.onInit and section "uninstall" for configuration
|
||||
@@ -79,11 +118,11 @@ section "install"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation" "$\"$INSTDIR$\""
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayIcon" "$\"$INSTDIR\logo.ico$\""
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "Publisher" "$\"${COMPANYNAME}$\""
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "Publisher" "${COMPANYNAME}"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "HelpLink" "$\"${HELPURL}$\""
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "URLUpdateInfo" "$\"${UPDATEURL}$\""
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "URLInfoAbout" "$\"${ABOUTURL}$\""
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayVersion" "$\"${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}$\""
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayVersion" "${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}"
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMajor" ${VERSIONMAJOR}
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMinor" ${VERSIONMINOR}
|
||||
# There is no option for modifying or repairing the install
|
||||
@@ -91,6 +130,9 @@ section "install"
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoRepair" 1
|
||||
# Set the INSTALLSIZE constant (!defined at the top of this script) so Add/Remove Programs can accurately report the size
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "EstimatedSize" ${INSTALLSIZE}
|
||||
|
||||
WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Run" ${APPNAME} "$INSTDIR\ptray.exe ${ARGS}"
|
||||
ExecShell "" "$INSTDIR\ptray.exe" "${ARGS}"
|
||||
sectionEnd
|
||||
|
||||
# Uninstaller
|
||||
@@ -107,7 +149,7 @@ function un.onInit
|
||||
functionEnd
|
||||
|
||||
section "uninstall"
|
||||
|
||||
!insertmacro TerminateApp
|
||||
# Remove Start Menu launcher
|
||||
delete "$SMPROGRAMS\${COMPANYNAME}\${APPNAME}.lnk"
|
||||
# Try to remove the Start Menu folder - this will only happen if it is empty
|
||||
@@ -115,6 +157,7 @@ section "uninstall"
|
||||
|
||||
# Remove files
|
||||
delete $INSTDIR\parity.exe
|
||||
delete $INSTDIR\ptray.exe
|
||||
delete $INSTDIR\logo.ico
|
||||
|
||||
# Always delete uninstaller as the last action
|
||||
@@ -131,5 +174,6 @@ section "uninstall"
|
||||
|
||||
# Remove uninstaller information from the registry
|
||||
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}"
|
||||
|
||||
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "${APPNAME}"
|
||||
sectionEnd
|
||||
|
||||
|
||||
BIN
nsis/logo.ico
BIN
nsis/logo.ico
Binary file not shown.
|
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 66 KiB |
Reference in New Issue
Block a user