当我使用NSIS安装应用程序时,它显示通知图标(系统托盘图标)。但是一旦重新启动/注销,图标就会在系统托盘中消失。
在安装时我正在调用“Display.exe”,它在“Section”中具有系统托盘功能。要在重新启动/注销后显示系统托盘功能,我们是否需要在任何其他位置添加此功能?
下面是我安装完成后显示系统托盘的现有代码:
!insertmacro MUI_LANGUAGE "English"
Section "MyApp"
File "C:\Desktop\Common\Display.exe"
# To notify and launch the application in the Systray
ExecShell "" "$INSTDIR\Display.exe"
SectionEnd
以下是服务相关代码:
WriteRegStr HKLM "SOFTWARE\EMR\4.01.00\Service" "Image" "mainserv.exe"
File "C:\Desktop\Common\mainserv.exe"
CreateShortcut "" "$InstDir\mainserv.exe" ; ***Added this line of code to start the service after reboot***
SimpleSC::InstallService "APC UPS Service" "APC UPS Service" "16" "2" "$INSTDIR\mainserv.exe" "" "" ""
Pop $0 ;
SimpleSC::SetServiceDescription "APC UPS Service" "Electronic Medical Record Service"
Pop $0 ;
SimpleSC::StartService "APC UPS Service" "" "30"
Pop $0 ;
通知图标(系统托盘图标)仅在其应用程序运行时存在。如果您希望图标在重新启动后保持不变,则必须安排应用程序在用户登录时启动。
您可以为the run key添加一个值:
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "MyApplication" '"$InstDir\MyApp.exe"' ; Can also be created in HKCU
或启动快捷方式:
CreateShortcut "$SMStartup\MyApp.lnk" "$InstDir\MyApp.exe"