当前位置:   article > 正文

程序打包步骤(QT,NSIS,VNISEdit)_vnis打包时,往注册表写入

vnis打包时,往注册表写入

1.打开一个QT程序,以Release方式编译
在这里插入图片描述
2.拷贝.exe文件至新创建一个空文件夹
在这里插入图片描述
在这里插入图片描述
cd /d D:\qt\QtTestPack
在这里插入图片描述
windeployqt testqtCodandMap.exe

在这里插入图片描述

3.打包软件

工具:

使用VNISEdit向导制作标准安装包

4.NSIS:在注册表中记录安装路径以便重装或升级时读取
第1步:读取注册表中关于安装路径的键值,如果没有,就使用默认路径。
InstallDirRegKey HKCU “Software\eBook Workshop” “”

第2步:在主区段中把安装路径写入注册表。

在这里插入图片描述

第3步:在卸载区段删除注册表中安装路径的键值。
在这里插入图片描述

安装包成功安装后,注册表信息中路径的存储截图
在这里插入图片描述

附录:
安装包脚本示例:

; 该脚本使用 HM VNISEdit 脚本编辑器向导产生

; 安装程序初始定义常量
!define PRODUCT_NAME "Lucky application"
!define PRODUCT_VERSION "2.2.2.2"
!define PRODUCT_PUBLISHER "Lucky My company, Inc."
!define PRODUCT_WEB_SITE "http://www.Luckymycompany.com"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\MessageStorage.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

SetCompressor lzma

; ------ MUI 现代界面定义 (1.67 版本以上兼容) ------
!include "MUI.nsh"

; MUI 预定义常量
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

; 欢迎页面
!insertmacro MUI_PAGE_WELCOME
; 许可协议页面
!insertmacro MUI_PAGE_LICENSE "License.txt"
; 安装目录选择页面
!insertmacro MUI_PAGE_DIRECTORY
; 安装过程页面
!insertmacro MUI_PAGE_INSTFILES
; 安装完成页面
!define MUI_FINISHPAGE_RUN "$INSTDIR\QCreator.exe"
!insertmacro MUI_PAGE_FINISH

; 安装卸载过程页面
!insertmacro MUI_UNPAGE_INSTFILES

; 安装界面包含的语言设置
!insertmacro MUI_LANGUAGE "SimpChinese"

; 安装预释放文件
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; ------ MUI 现代界面定义结束 ------

; Name设置安装程序的名称
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Setup.exe"

;常量通常用在 InstallDir 属性里 $PROGRAMFILES:程序文件目录(通常为 C:\Program Files 但是运行时会检测);默认安装目录
InstallDir "$PROGRAMFILES\Lucky-My application"
;InstallDirRegKey属性让安装程序去检测一注册表里的一个字串,如果该字串可用那么把它用来作为安装目录,
;如果预置了该属性,当指定的注册表键可用时它会越过 InstallDir 指定的字串,否则使用默认的 InstallDir 指定值。
InstallDirRegKey HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
ShowInstDetails show
ShowUnInstDetails show

Section "MainSection" SEC01
  SetOutPath "$INSTDIR\bearer"
  ;SetOverwrite的属性:on|off|try|ifnewer|ifdiff|lastused
  SetOverwrite ifnewer
  File "..\binaries\windows\msvc2015\x86\release\bearer\qgenericbearer.dll"
  SetOutPath "$INSTDIR"
  File "..\binaries\windows\msvc2015\x86\release\config.xls"
  CreateDirectory "$SMPROGRAMS\Lucky-My application"
  CreateShortCut "$SMPROGRAMS\Lucky-My application\Lucky-My application.lnk" "$INSTDIR\QCreator.exe"
  CreateShortCut "$DESKTOP\Lucky-My application.lnk" "$INSTDIR\QCreator.exe"
  File "..\binaries\windows\msvc2015\x86\release\D3Dcompiler_47.dll"
  File "..\binaries\windows\msvc2015\x86\release\driver.db"
  File "..\binaries\windows\msvc2015\x86\release\firmware.db"
  SetOutPath "$INSTDIR\iconengines"
  File "..\binaries\windows\msvc2015\x86\release\iconengines\qsvgicon.dll"
  SetOutPath "$INSTDIR\imageformats"
  File "..\binaries\windows\msvc2015\x86\release\imageformats\qgif.dll"
  File "..\binaries\windows\msvc2015\x86\release\imageformats\qicns.dll"
  File "..\binaries\windows\msvc2015\x86\release\imageformats\qico.dll"
  File "..\binaries\windows\msvc2015\x86\release\imageformats\qjpeg.dll"
  File "..\binaries\windows\msvc2015\x86\release\imageformats\qsvg.dll"
  File "..\binaries\windows\msvc2015\x86\release\imageformats\qtga.dll"
  File "..\binaries\windows\msvc2015\x86\release\imageformats\qtiff.dll"
  File "..\binaries\windows\msvc2015\x86\release\imageformats\qwbmp.dll"
  File "..\binaries\windows\msvc2015\x86\release\imageformats\qwebp.dll"
  SetOutPath "$INSTDIR"
  File "..\binaries\windows\msvc2015\x86\release\libEGL.dll"
  File "..\binaries\windows\msvc2015\x86\release\libGLESV2.dll"
  File "..\binaries\windows\msvc2015\x86\release\map - 副本.xml"
  File "..\binaries\windows\msvc2015\x86\release\map-1.xml"
  File "..\binaries\windows\msvc2015\x86\release\map.xml"
  File "..\binaries\windows\msvc2015\x86\release\MessageStorage.exe"
  File "..\binaries\windows\msvc2015\x86\release\opengl32sw.dll"
  SetOutPath "$INSTDIR\platforms"
  File "..\binaries\windows\msvc2015\x86\release\platforms\qwindows.dll"
  SetOutPath "$INSTDIR"
  File "..\binaries\windows\msvc2015\x86\release\plink.exe"
  SetOutPath "$INSTDIR\plugins"
  File "..\binaries\windows\msvc2015\x86\release\plugins\DefaultProjectPlugin.dll"
  File "..\binaries\windows\msvc2015\x86\release\plugins\DefaultProjectPlugin.exp"
  File "..\binaries\windows\msvc2015\x86\release\plugins\DefaultProjectPlugin.lib"
  File "..\binaries\windows\msvc2015\x86\release\plugins\demoPlugin.dll"
  File "..\binaries\windows\msvc2015\x86\release\plugins\demoPlugin.exp"
  File "..\binaries\windows\msvc2015\x86\release\plugins\demoPlugin.lib"
  File "..\binaries\windows\msvc2015\x86\release\plugins\FirManageplugin.dll"
  File "..\binaries\windows\msvc2015\x86\release\plugins\FirManageplugin.exp"
  File "..\binaries\windows\msvc2015\x86\release\plugins\FirManageplugin.lib"
  File "..\binaries\windows\msvc2015\x86\release\plugins\FtpPlugin.dll"
  File "..\binaries\windows\msvc2015\x86\release\plugins\FtpPlugin.exp"
  File "..\binaries\windows\msvc2015\x86\release\plugins\FtpPlugin.lib"
  File "..\binaries\windows\msvc2015\x86\release\plugins\OutputWidgetPlugin.dll"
  File "..\binaries\windows\msvc2015\x86\release\plugins\OutputWidgetPlugin.exp"
  File "..\binaries\windows\msvc2015\x86\release\plugins\OutputWidgetPlugin.lib"
  File "..\binaries\windows\msvc2015\x86\release\plugins\pluginsBrowserPlugin.dll"
  File "..\binaries\windows\msvc2015\x86\release\plugins\ProcessManagerPlugin.dll"
  File "..\binaries\windows\msvc2015\x86\release\plugins\ProcessManagerPlugin.exp"
  File "..\binaries\windows\msvc2015\x86\release\plugins\ProcessManagerPlugin.lib"
  File "..\binaries\windows\msvc2015\x86\release\plugins\RtdbPlugin.dll"
  File "..\binaries\windows\msvc2015\x86\release\plugins\RtdbPlugin.exp"
  File "..\binaries\windows\msvc2015\x86\release\plugins\RtdbPlugin.lib"
  File "..\binaries\windows\msvc2015\x86\release\plugins\SignInPlugin.dll"
  File "..\binaries\windows\msvc2015\x86\release\plugins\SignInPlugin.exp"
  File "..\binaries\windows\msvc2015\x86\release\plugins\SignInPlugin.lib"
  File "..\binaries\windows\msvc2015\x86\release\plugins\SocketPortPlugin.dll"
  File "..\binaries\windows\msvc2015\x86\release\plugins\SocketPortPlugin.exp"
  File "..\binaries\windows\msvc2015\x86\release\plugins\SocketPortPlugin.lib"
  SetOutPath "$INSTDIR"
  File "..\binaries\windows\msvc2015\x86\release\pscp.exe"
  File "..\binaries\windows\msvc2015\x86\release\QCreator.exe"
  File "..\binaries\windows\msvc2015\x86\release\Qt5Core.dll"
  File "..\binaries\windows\msvc2015\x86\release\Qt5Gui.dll"
  File "..\binaries\windows\msvc2015\x86\release\Qt5Network.dll"
  File "..\binaries\windows\msvc2015\x86\release\Qt5Sql.dll"
  File "..\binaries\windows\msvc2015\x86\release\Qt5Svg.dll"
  File "..\binaries\windows\msvc2015\x86\release\Qt5Widgets.dll"
  File "..\binaries\windows\msvc2015\x86\release\Qt5Xml.dll"
  File "..\binaries\windows\msvc2015\x86\release\script.db"
  SetOutPath "$INSTDIR\sqldrivers"
  File "..\binaries\windows\msvc2015\x86\release\sqldrivers\qsqlite.dll"
  File "..\binaries\windows\msvc2015\x86\release\sqldrivers\qsqlmysql.dll"
  File "..\binaries\windows\msvc2015\x86\release\sqldrivers\qsqlodbc.dll"
  File "..\binaries\windows\msvc2015\x86\release\sqldrivers\qsqlpsql.dll"
  SetOutPath "$INSTDIR\styles"
  File "..\binaries\windows\msvc2015\x86\release\styles\qwindowsvistastyle.dll"
  SetOutPath "$INSTDIR\tools"
  File "..\binaries\windows\msvc2015\x86\release\tools\SQLManagement1.exe"
  File "..\binaries\windows\msvc2015\x86\release\tools\xmllist.exe"
  SetOutPath "$INSTDIR\translations"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_ar.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_bg.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_ca.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_cs.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_da.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_de.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_en.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_es.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_fi.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_fr.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_gd.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_he.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_hu.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_it.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_ja.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_ko.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_lv.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_pl.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_ru.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_sk.qm"
  File "..\binaries\windows\msvc2015\x86\release\translations\qt_uk.qm"
  SetOutPath "$INSTDIR"
  File "..\binaries\windows\msvc2015\x86\release\zh.qm"
  File "..\binaries\windows\msvc2015\x86\release\zh.ts"
  File "vc_redist.x86.exe"
  ExecWait '"$INSTDIR\vc_redist.x86.exe" /q'
SectionEnd

Section -AdditionalIcons
  WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
 
  CreateShortCut "$SMPROGRAMS\Lucky-My application\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
  CreateShortCut "$SMPROGRAMS\Lucky-My application\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
  WriteUninstaller "$INSTDIR\uninst.exe"
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\MessageStorage.exe"
  WriteRegStr HKCU "Software\QCreator Path" "" $INSTDIR
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\MessageStorage.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd
                                                                      
/******************************
 *  以下是安装程序的卸载部分  *
 ******************************/

Section Uninstall
  Delete "$INSTDIR\${PRODUCT_NAME}.url"
  Delete "$INSTDIR\uninst.exe"
  Delete "$INSTDIR\vc_redist.x86.exe"
  Delete "$INSTDIR\zh.ts"
  Delete "$INSTDIR\zh.qm"
  Delete "$INSTDIR\translations\qt_uk.qm"
  Delete "$INSTDIR\translations\qt_sk.qm"
  Delete "$INSTDIR\translations\qt_ru.qm"
  Delete "$INSTDIR\translations\qt_pl.qm"
  Delete "$INSTDIR\translations\qt_lv.qm"
  Delete "$INSTDIR\translations\qt_ko.qm"
  Delete "$INSTDIR\translations\qt_ja.qm"
  Delete "$INSTDIR\translations\qt_it.qm"
  Delete "$INSTDIR\translations\qt_hu.qm"
  Delete "$INSTDIR\translations\qt_he.qm"
  Delete "$INSTDIR\translations\qt_gd.qm"
  Delete "$INSTDIR\translations\qt_fr.qm"
  Delete "$INSTDIR\translations\qt_fi.qm"
  Delete "$INSTDIR\translations\qt_es.qm"
  Delete "$INSTDIR\translations\qt_en.qm"
  Delete "$INSTDIR\translations\qt_de.qm"
  Delete "$INSTDIR\translations\qt_da.qm"
  Delete "$INSTDIR\translations\qt_cs.qm"
  Delete "$INSTDIR\translations\qt_ca.qm"
  Delete "$INSTDIR\translations\qt_bg.qm"
  Delete "$INSTDIR\translations\qt_ar.qm"
  Delete "$INSTDIR\tools\xmllist.exe"
  Delete "$INSTDIR\tools\SQLManagement1.exe"
  Delete "$INSTDIR\styles\qwindowsvistastyle.dll"
  Delete "$INSTDIR\sqldrivers\qsqlpsql.dll"
  Delete "$INSTDIR\sqldrivers\qsqlodbc.dll"
  Delete "$INSTDIR\sqldrivers\qsqlmysql.dll"
  Delete "$INSTDIR\sqldrivers\qsqlite.dll"
  Delete "$INSTDIR\script.db"
  Delete "$INSTDIR\Qt5Xml.dll"
  Delete "$INSTDIR\Qt5Widgets.dll"
  Delete "$INSTDIR\Qt5Svg.dll"
  Delete "$INSTDIR\Qt5Sql.dll"
  Delete "$INSTDIR\Qt5Network.dll"
  Delete "$INSTDIR\Qt5Gui.dll"
  Delete "$INSTDIR\Qt5Core.dll"
  Delete "$INSTDIR\QCreator.exe"
  Delete "$INSTDIR\pscp.exe"
  Delete "$INSTDIR\plugins\SocketPortPlugin.lib"
  Delete "$INSTDIR\plugins\SocketPortPlugin.exp"
  Delete "$INSTDIR\plugins\SocketPortPlugin.dll"
  Delete "$INSTDIR\plugins\SignInPlugin.lib"
  Delete "$INSTDIR\plugins\SignInPlugin.exp"
  Delete "$INSTDIR\plugins\SignInPlugin.dll"
  Delete "$INSTDIR\plugins\RtdbPlugin.lib"
  Delete "$INSTDIR\plugins\RtdbPlugin.exp"
  Delete "$INSTDIR\plugins\RtdbPlugin.dll"
  Delete "$INSTDIR\plugins\ProcessManagerPlugin.lib"
  Delete "$INSTDIR\plugins\ProcessManagerPlugin.exp"
  Delete "$INSTDIR\plugins\ProcessManagerPlugin.dll"
  Delete "$INSTDIR\plugins\pluginsBrowserPlugin.dll"
  Delete "$INSTDIR\plugins\OutputWidgetPlugin.lib"
  Delete "$INSTDIR\plugins\OutputWidgetPlugin.exp"
  Delete "$INSTDIR\plugins\OutputWidgetPlugin.dll"
  Delete "$INSTDIR\plugins\FtpPlugin.lib"
  Delete "$INSTDIR\plugins\FtpPlugin.exp"
  Delete "$INSTDIR\plugins\FtpPlugin.dll"
  Delete "$INSTDIR\plugins\FirManageplugin.lib"
  Delete "$INSTDIR\plugins\FirManageplugin.exp"
  Delete "$INSTDIR\plugins\FirManageplugin.dll"
  Delete "$INSTDIR\plugins\demoPlugin.lib"
  Delete "$INSTDIR\plugins\demoPlugin.exp"
  Delete "$INSTDIR\plugins\demoPlugin.dll"
  Delete "$INSTDIR\plugins\DefaultProjectPlugin.lib"
  Delete "$INSTDIR\plugins\DefaultProjectPlugin.exp"
  Delete "$INSTDIR\plugins\DefaultProjectPlugin.dll"
  Delete "$INSTDIR\plink.exe"
  Delete "$INSTDIR\platforms\qwindows.dll"
  Delete "$INSTDIR\opengl32sw.dll"
  Delete "$INSTDIR\MessageStorage.exe"
  Delete "$INSTDIR\map.xml"
  Delete "$INSTDIR\map-1.xml"
  Delete "$INSTDIR\map - 副本.xml"
  Delete "$INSTDIR\libGLESV2.dll"
  Delete "$INSTDIR\libEGL.dll"
  Delete "$INSTDIR\imageformats\qwebp.dll"
  Delete "$INSTDIR\imageformats\qwbmp.dll"
  Delete "$INSTDIR\imageformats\qtiff.dll"
  Delete "$INSTDIR\imageformats\qtga.dll"
  Delete "$INSTDIR\imageformats\qsvg.dll"
  Delete "$INSTDIR\imageformats\qjpeg.dll"
  Delete "$INSTDIR\imageformats\qico.dll"
  Delete "$INSTDIR\imageformats\qicns.dll"
  Delete "$INSTDIR\imageformats\qgif.dll"
  Delete "$INSTDIR\iconengines\qsvgicon.dll"
  Delete "$INSTDIR\firmware.db"
  Delete "$INSTDIR\driver.db"
  Delete "$INSTDIR\D3Dcompiler_47.dll"
  Delete "$INSTDIR\config.xls"
  Delete "$INSTDIR\bearer\qgenericbearer.dll"

  Delete "$SMPROGRAMS\Lucky-My application\Uninstall.lnk"
  Delete "$SMPROGRAMS\Lucky-My application\Website.lnk"
  Delete "$DESKTOP\Lucky-My application.lnk"
  Delete "$SMPROGRAMS\Lucky-My application\Lucky-My application.lnk"


  RMDir "$SMPROGRAMS\Lucky-My application"
  RMDir "$INSTDIR\translations"
  RMDir "$INSTDIR\tools"
  RMDir "$INSTDIR\styles"
  RMDir "$INSTDIR\sqldrivers"
  RMDir "$INSTDIR\plugins"
  RMDir "$INSTDIR\platforms"
  RMDir "$INSTDIR\imageformats"
  RMDir "$INSTDIR\iconengines"
  RMDir "$INSTDIR\bearer"

  RMDir "$INSTDIR"

  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
  DeleteRegKey /ifempty  ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  DeleteRegKey /ifempty HKCU "Software\QCreator Path"
  SetAutoClose true
SectionEnd

#-- 根据 NSIS 脚本编辑规则,所有 Function 区段必须放置在 Section 区段之后编写,以避免安装程序出现未可预知的问题。--#

Function un.onInit
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "你确实要完全移除 $(^Name) ,及其所有的组件?" IDYES +2
  Abort
FunctionEnd

Function un.onUninstSuccess
  HideWindow
  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地从你的计算机移除。"
FunctionEnd
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329

读取注册表路径示例

; 该脚本使用 HM VNISEdit 脚本编辑器向导产生

; 安装程序初始定义常量
!define PRODUCT_NAME "DBFILE application"
!define PRODUCT_VERSION "1.1.1.1"
!define PRODUCT_PUBLISHER "DBFILE company, Inc."
!define PRODUCT_WEB_SITE "http://www.DBFILEmycompany.com"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

SetCompressor lzma

; ------ MUI 现代界面定义 (1.67 版本以上兼容) ------
!include "MUI.nsh"

; MUI 预定义常量
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

; 语言选择窗口常量设置
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"

; 欢迎页面
!insertmacro MUI_PAGE_WELCOME
; 许可协议页面

; 安装目录选择页面
!insertmacro MUI_PAGE_DIRECTORY
; 安装过程页面
!insertmacro MUI_PAGE_INSTFILES
; 安装完成页面
!insertmacro MUI_PAGE_FINISH

; 安装卸载过程页面
!insertmacro MUI_UNPAGE_INSTFILES

; 安装界面包含的语言设置
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "SimpChinese"

; 安装预释放文件
!insertmacro MUI_RESERVEFILE_LANGDLL
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; ------ MUI 现代界面定义结束 ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "dbFileSetup.exe"
InstallDir "$PROGRAMFILES\My applicationDBFILE"
InstallDirRegKey HKCU "Software\QCreator Path" ""
ShowInstDetails show
ShowUnInstDetails show

Section "MainSection" SEC01
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File "script.db"
  File "firmware.db"
  File "driver.db"
SectionEnd

Section -AdditionalIcons
  WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
  CreateDirectory "$SMPROGRAMS\My applicationDBFILE"
  CreateShortCut "$SMPROGRAMS\My applicationDBFILE\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
  CreateShortCut "$SMPROGRAMS\My applicationDBFILE\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
  WriteUninstaller "$INSTDIR\uninst.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd

#-- 根据 NSIS 脚本编辑规则,所有 Function 区段必须放置在 Section 区段之后编写,以避免安装程序出现未可预知的问题。--#

Function .onInit
  !insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd

/******************************
 *  以下是安装程序的卸载部分  *
 ******************************/

Section Uninstall
  Delete "$INSTDIR\${PRODUCT_NAME}.url"
  Delete "$INSTDIR\uninst.exe"
  Delete "$INSTDIR\driver.db"
  Delete "$INSTDIR\firmware.db"
  Delete "$INSTDIR\script.db"

  Delete "$SMPROGRAMS\My applicationDBFILE\Uninstall.lnk"
  Delete "$SMPROGRAMS\My applicationDBFILE\Website.lnk"

  RMDir "$SMPROGRAMS\My applicationDBFILE"

  RMDir "$INSTDIR"

  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  SetAutoClose true
SectionEnd

#-- 根据 NSIS 脚本编辑规则,所有 Function 区段必须放置在 Section 区段之后编写,以避免安装程序出现未可预知的问题。--#

Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "你确实要完全移除 $(^Name) ,及其所有的组件?" IDYES +2
  Abort
FunctionEnd

Function un.onUninstSuccess
  HideWindow
  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地从你的计算机移除。"
FunctionEnd```

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/496677
推荐阅读
相关标签
  

闽ICP备14008679号