杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2020|回复: 0

DotNet版本检测

[复制链接]
发表于 2019-11-24 23:05:02 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

您需要 登录 才可以下载或查看,没有账号?立即注册

x


  1. ; LogicLib extensions for checking Microsoft .NET Framework versions and service packs.
  2. ;
  3. ; Latests Updates by Brandon Hansen, KG6YPI (RemoteHams.com)
  4. ; Dec 26, 2011 - .NET Framework 4.0 detection fixes - client profile not being found
  5. ; Dec 07, 2010 - .NET Framework 4.0 detection added by Brandon Hansen (KG6YPI)
  6. ;
  7. ; Usage examples:
  8. ;
  9. ; ${If} ${HasDotNet4.0}
  10. ; DetailPrint "Microsoft .NET Framework 4.0 installed."
  11. ; ${If} ${DOTNETVER_4_0} AtLeastDotNetServicePack 1
  12. ; DetailPrint "Microsoft .NET Framework 4.0 is at least SP1."
  13. ; ${Else}
  14. ; DetailPrint "Microsoft .NET Framework 4.0 SP1 not installed."
  15. ; ${EndIf}
  16. ; ${If} ${DOTNETVER_4_0} HasDotNetClientProfile 1
  17. ; DetailPrint "Microsoft .NET Framework 4.0 (Client Profile) available."
  18. ; ${EndIf}
  19. ; ${If} ${DOTNETVER_4_0} HasDotNetFullProfile 1
  20. ; DetailPrint "Microsoft .NET Framework 4.0 (Full Profile) available."
  21. ; ${EndIf}
  22. ; ${If} ${DOTNETVER_4_0} HasDotNetFullProfile 0
  23. ; DetailPrint "Microsoft .NET Framework 4.0 (Full Profile) not available."
  24. ; ${EndIf}
  25. ; ${EndIf}


  26. !verbose push
  27. !verbose 3

  28. !ifndef ___DOTNETVER__NSH___
  29. !define ___DOTNETVER__NSH___

  30. !include LogicLib.nsh
  31. !include Util.nsh

  32. # constants

  33. !define DOTNETVER_1_0 "1.0"
  34. !define DOTNETVER_1_1 "1.1"
  35. !define DOTNETVER_2_0 "2.0"
  36. !define DOTNETVER_3_0 "3.0"
  37. !define DOTNETVER_3_5 "3.5"
  38. !define DOTNETVER_4_0 "4.0"

  39. # variable declaration

  40. Var /GLOBAL __DONTNET_FOUNDVER

  41. !macro __DotNetVer_DeclareVars
  42. !ifndef __DOTNETVER_VARS_DECLARED
  43. !define __DOTNETVER_VARS_DECLARED
  44. Var /GLOBAL __DOTNET_1.0
  45. Var /GLOBAL __DOTNET_1.1
  46. Var /GLOBAL __DOTNET_2.0
  47. Var /GLOBAL __DOTNET_3.0
  48. Var /GLOBAL __DOTNET_3.5
  49. Var /GLOBAL __DOTNET_4.0

  50. Var /GLOBAL __DOTNETVER_1.0_SP
  51. Var /GLOBAL __DOTNETVER_1.1_SP
  52. Var /GLOBAL __DOTNETVER_2.0_SP
  53. Var /GLOBAL __DOTNETVER_3.0_SP
  54. Var /GLOBAL __DOTNETVER_3.5_SP
  55. Var /GLOBAL __DOTNETVER_4.0_SP

  56. Var /GLOBAL __DOTNET_1.0_CLIENT
  57. Var /GLOBAL __DOTNET_1.1_CLIENT
  58. Var /GLOBAL __DOTNET_2.0_CLIENT
  59. Var /GLOBAL __DOTNET_3.0_CLIENT
  60. Var /GLOBAL __DOTNET_3.5_CLIENT
  61. Var /GLOBAL __DOTNET_4.0_CLIENT

  62. Var /GLOBAL __DOTNET_1.0_FULL
  63. Var /GLOBAL __DOTNET_1.1_FULL
  64. Var /GLOBAL __DOTNET_2.0_FULL
  65. Var /GLOBAL __DOTNET_3.0_FULL
  66. Var /GLOBAL __DOTNET_3.5_FULL
  67. Var /GLOBAL __DOTNET_4.0_FULL

  68. StrCpy $__DOTNET_1.0 0
  69. StrCpy $__DOTNET_1.1 0
  70. StrCpy $__DOTNET_2.0 0
  71. StrCpy $__DOTNET_3.0 0
  72. StrCpy $__DOTNET_3.5 0
  73. StrCpy $__DOTNET_4.0 0

  74. StrCpy $__DOTNETVER_1.0_SP 0
  75. StrCpy $__DOTNETVER_1.1_SP 0
  76. StrCpy $__DOTNETVER_2.0_SP 0
  77. StrCpy $__DOTNETVER_3.0_SP 0
  78. StrCpy $__DOTNETVER_3.5_SP 0
  79. StrCpy $__DOTNETVER_4.0_SP 0

  80. StrCpy $__DOTNET_1.0_CLIENT 0
  81. StrCpy $__DOTNET_1.1_CLIENT 0
  82. StrCpy $__DOTNET_2.0_CLIENT 0
  83. StrCpy $__DOTNET_3.0_CLIENT 0
  84. StrCpy $__DOTNET_3.5_CLIENT 0
  85. StrCpy $__DOTNET_4.0_CLIENT 0

  86. StrCpy $__DOTNET_1.0_FULL 0
  87. StrCpy $__DOTNET_1.1_FULL 0
  88. StrCpy $__DOTNET_2.0_FULL 0
  89. StrCpy $__DOTNET_3.0_FULL 0
  90. StrCpy $__DOTNET_3.5_FULL 0
  91. StrCpy $__DOTNET_4.0_FULL 0

  92. !endif
  93. !macroend


  94. # lazy initialization macro

  95. !macro __DotNetVer_InitVars
  96. # only calculate version once
  97. StrCmp $__DONTNET_FOUNDVER "" dotnetver.noveryet
  98. Return

  99. dotnetver.noveryet:
  100. !insertmacro __DotNetVer_DeclareVars

  101. Push $0 ;registry count
  102. Push $1 ;registry key
  103. Push $2 ;version number
  104. Push $3 ;installed
  105. Push $4 ;service pack number
  106. Push $8 ;strLen helper var

  107. StrCpy $0 0

  108. dotnetver.startenum:

  109. EnumRegKey $1 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP" $0
  110. StrCmp $1 "" dotnetver.done

  111. IntOp $0 $0 + 1

  112. StrCpy $2 $1 1 0
  113. StrCmp $2 "v" +1 dotnetver.startenum
  114. StrCpy $2 $1 3 1

  115. ; Check for .NET 1.0 to 3.5
  116. ReadRegDWORD $3 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\$1" "Install"
  117. ReadRegDWORD $4 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\$1" "SP"
  118. ; This is a sanity check that works on .NET 1.0 to 3.5
  119. ; if it fails check for dotnet 4
  120. IntCmp $3 0 dotnetcheck.40
  121. StrCmp $2 ${DOTNETVER_1_0} dotnetver.10
  122. StrCmp $2 ${DOTNETVER_1_1} dotnetver.11
  123. StrCmp $2 ${DOTNETVER_2_0} dotnetver.20
  124. StrCmp $2 ${DOTNETVER_3_0} dotnetver.30
  125. StrCmp $2 ${DOTNETVER_3_5} dotnetver.35
  126. dotnetcheck.40:
  127. StrCmp $2 ${DOTNETVER_4_0} dotnetver.40
  128. StrCmp $2 "4" dotnetver.40

  129. Goto dotnetver.startenum

  130. dotnetver.10:
  131. StrCpy $__DOTNET_1.0 1
  132. StrCpy $__DOTNETVER_1.0_SP $4
  133. StrCpy $__DOTNET_1.0_FULL 1
  134. Goto dotnetver.startenum
  135. dotnetver.11:
  136. StrCpy $__DOTNET_1.1 1
  137. StrCpy $__DOTNETVER_1.1_SP $4
  138. StrCpy $__DOTNET_1.1_FULL 1
  139. Goto dotnetver.startenum
  140. dotnetver.20:
  141. StrCpy $__DOTNET_2.0 1
  142. StrCpy $__DOTNETVER_2.0_SP $4
  143. StrCpy $__DOTNET_2.0_FULL 1
  144. Goto dotnetver.startenum
  145. dotnetver.30:
  146. StrCpy $__DOTNET_3.0 1
  147. StrCpy $__DOTNETVER_3.0_SP $4
  148. StrCpy $__DOTNET_3.0_FULL 1
  149. Goto dotnetver.startenum
  150. dotnetver.35:
  151. StrCpy $__DOTNET_3.5 1
  152. StrCpy $__DOTNETVER_3.5_SP $4
  153. StrCpy $__DOTNET_3.5_FULL 1
  154. Goto dotnetver.startenum

  155. dotnetver.40:
  156. ; Check for .NET 4.0 (Full Profile)
  157. ReadRegDWORD $3 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" "Install"
  158. ReadRegDWORD $4 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" "SP"
  159. StrLen $8 $3
  160. IntCmp $8 0 dotnetcheck.40c
  161. IntCmp $3 0 dotnetcheck.40c
  162. StrCmp $2 ${DOTNETVER_4_0} dotnetver.40_Full
  163. StrCmp $2 "4" dotnetver.40_Full
  164. dotnetcheck.40c:
  165. ; Check for .NET 4.0 (Client Profile)
  166. ReadRegDWORD $3 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client" "Install"
  167. ReadRegDWORD $4 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client" "SP"
  168. StrLen $8 $3
  169. IntCmp $8 0 dotnetver.startenum
  170. IntCmp $3 0 dotnetver.startenum
  171. StrCmp $2 ${DOTNETVER_4_0} dotnetver.40_Client
  172. StrCmp $2 "4" dotnetver.40_Client
  173. Goto dotnetver.startenum
  174. dotnetver.40_Full:
  175. StrCpy $__DOTNET_4.0 1
  176. StrCpy $__DOTNETVER_4.0_SP $4
  177. StrCpy $__DOTNET_4.0_FULL 1
  178. Goto dotnetcheck.40c ; continue looking for other profiles
  179. dotnetver.40_Client:
  180. StrCpy $__DOTNET_4.0 1
  181. StrCpy $__DOTNETVER_4.0_SP $4
  182. StrCpy $__DOTNET_4.0_CLIENT 1
  183. Goto dotnetver.startenum

  184. dotnetver.done:

  185. StrCpy $__DONTNET_FOUNDVER "1"

  186. Pop $8
  187. Pop $4
  188. Pop $3
  189. Pop $2
  190. Pop $1
  191. Pop $0
  192. !macroend

  193. !macro _HasDotNet _a _b _t _f
  194. ${CallArtificialFunction} __DotNetVer_InitVars

  195. !insertmacro _= `$__DOTNET_${_b}` `1` `${_t}` `${_f}`
  196. !macroend

  197. !macro __DotNetVer_DefineTest Ver
  198. !define HasDotNet${Ver} `"" HasDotNet ${Ver}`
  199. !macroend

  200. !insertmacro __DotNetVer_DefineTest ${DOTNETVER_1_0}
  201. !insertmacro __DotNetVer_DefineTest ${DOTNETVER_1_1}
  202. !insertmacro __DotNetVer_DefineTest ${DOTNETVER_2_0}
  203. !insertmacro __DotNetVer_DefineTest ${DOTNETVER_3_0}
  204. !insertmacro __DotNetVer_DefineTest ${DOTNETVER_3_5}
  205. !insertmacro __DotNetVer_DefineTest ${DOTNETVER_4_0}

  206. !macro _AtLeastDotNetServicePack _a _b _t _f
  207. ${CallArtificialFunction} __DotNetVer_InitVars

  208. !insertmacro _>= `$__DOTNETVER_${_a}_SP` `${_b}` `${_t}` `${_f}`
  209. !macroend
  210. !define AtLeastDotNetServicePack `AtLeastDotNetServicePack`


  211. !macro _AtMostDotNetServicePack _a _b _t _f
  212. ${CallArtificialFunction} __DotNetVer_InitVars

  213. !insertmacro _<= `$__DOTNETVER_${_a}_SP` `${_b}` `${_t}` `${_f}`
  214. !macroend
  215. !define AtMostDotNetServicePack `AtMostDotNetServicePack`


  216. !macro _IsDotNetServicePack _a _b _t _f
  217. ${CallArtificialFunction} __DotNetVer_InitVars

  218. !insertmacro _= `$__DOTNETVER_${_a}_SP` `${_b}` `${_t}` `${_f}`
  219. !macroend
  220. !define IsDotNetServicePack `IsDotNetServicePack`

  221. !macro _HasDotNetClientProfile _a _b _t _f
  222. ${CallArtificialFunction} __DotNetVer_InitVars

  223. !insertmacro _= `$__DOTNET_${_a}_CLIENT` `${_b}` `${_t}` `${_f}`
  224. !macroend
  225. !define HasDotNetClientProfile `HasDotNetClientProfile`

  226. !macro _HasDotNetFullProfile _a _b _t _f
  227. ${CallArtificialFunction} __DotNetVer_InitVars

  228. !insertmacro _= `$__DOTNET_${_a}_FULL` `${_b}` `${_t}` `${_f}`
  229. !macroend
  230. !define HasDotNetFullProfile `HasDotNetFullProfile`

  231. # done

  232. !endif # !___DOTNETVER__NSH___

  233. !verbose pop
  234. 2. 准备打包文件。运行NSIS的VNISEdit 2.0.3编译环境。文件 -> 新建脚本(向导),用向导构建基本打包脚本框架。



  235. 3.修改向导生成的nsi文件。修改脚本、编译脚本、安装测试。不断完善。本实例包括.NET Framework 2.0 SP1检测和安装,DLL注册和卸载,已安装版本检测和重安装处理等,供学习参考。

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

  237. ; 安装程序初始定义常量
  238. !define VER_MAJOR 2
  239. !define VER_MINOR 4
  240. !define VER_REVISION 5
  241. !define VER_BUILD 0
  242. !define VERSION `${VER_MAJOR}.${VER_MINOR}.${VER_REVISION}.${VER_BUILD}`

  243. !define PRODUCT_NAME "Hello"
  244. !define PRODUCT_VERSION '${VERSION}'
  245. !define PRODUCT_PUBLISHER "My company, Inc."
  246. !define PRODUCT_WEB_SITE "http://www.mycompany.com"
  247. !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\Hello.exe"
  248. !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
  249. !define PRODUCT_UNINST_ROOT_KEY "HKLM"

  250. SetCompressor lzma

  251. RequestExecutionLevel admin

  252. ; ------ MUI 现代界面定义 (1.67 版本以上兼容) ------
  253. !include "MUI.nsh"
  254. !include "LogicLib.nsh"
  255. !include "DotNetVer.nsh"
  256. !include "WordFunc.nsh"


  257. !ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD

  258. !insertmacro VersionCompare

  259. !endif


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

  264. ; 欢迎页面
  265. !insertmacro MUI_PAGE_WELCOME
  266. ; 许可协议页面
  267. !insertmacro MUI_PAGE_LICENSE "bin\COPYING.txt"
  268. ; 安装目录选择页面
  269. !insertmacro MUI_PAGE_DIRECTORY
  270. ; 安装过程页面
  271. !insertmacro MUI_PAGE_INSTFILES
  272. ; 安装完成页面
  273. !define MUI_FINISHPAGE_RUN "$INSTDIR\Hello.exe"
  274. !insertmacro MUI_PAGE_FINISH

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

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

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

  282. Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
  283. OutFile "Setup.exe"
  284. InstallDir "$PROGRAMFILES\Hello"
  285. InstallDirRegKey HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
  286. ShowInstDetails show
  287. ShowUnInstDetails show
  288. BrandingText " "

  289. Section "MainSection" SEC01
  290. ;Shortcuts removal fails on Windows Vista
  291. SetShellVarContext all

  292. ;安装.NET Framework 2.0 SP1
  293. ${If} ${HasDotNet2.0}
  294. DetailPrint "Microsoft .NET Framework 2.0 installed."
  295. ${If} ${DOTNETVER_2_0} IsDotNetServicePack 1
  296. DetailPrint "Microsoft .NET Framework 2.0 SP1 installed."
  297. ${EndIf}
  298. ${If} ${DOTNETVER_2_0} IsDotNetServicePack 2
  299. DetailPrint "Microsoft .NET Framework 2.0 SP2 installed."
  300. ${EndIf}
  301. ${If} ${DOTNETVER_2_0} IsDotNetServicePack 3
  302. DetailPrint "Microsoft .NET Framework 2.0 SP3 installed."
  303. ${EndIf}
  304. ${Else}
  305. DetailPrint "正在安装 .NET Framework 2.0 SP1"
  306. SetDetailsPrint listonly
  307. SetOutPath "$INSTDIR"
  308. SetOverwrite on
  309. File "bin\NetFx20SP1_x86.exe"
  310. ExecWait '"$INSTDIR\NetFx20SP1_x86.exe" /quiet /norestart'
  311. ${EndIf}

  312. SetOutPath "$INSTDIR"
  313. SetOverwrite ifnewer
  314. File "bin\COPYING.txt"
  315. CreateDirectory "$SMPROGRAMS\Hello"
  316. CreateShortCut "$SMPROGRAMS\Hello\Hello.lnk" "$INSTDIR\Hello.exe"
  317. CreateShortCut "$DESKTOP\Hello.lnk" "$INSTDIR\Hello.exe"
  318. File "bin\Hello.exe"

  319. ;register dll
  320. File "bin\MSCOMM32.OCX"
  321. RegDLL "$INSTDIR\MSCOMM32.OCX"
  322. SectionEnd

  323. Section -AdditionalIcons
  324. ;Shortcuts removal fails on Windows Vista
  325. SetShellVarContext all

  326. WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
  327. CreateShortCut "$SMPROGRAMS\Hello\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
  328. CreateShortCut "$SMPROGRAMS\Hello\Uninstall.lnk" "$INSTDIR\uninst.exe"
  329. SectionEnd

  330. Section -Post
  331. WriteUninstaller "$INSTDIR\uninst.exe"
  332. WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\Hello.exe"
  333. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
  334. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
  335. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\Hello.exe"
  336. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  337. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  338. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
  339. SectionEnd

  340. /******************************
  341. * 以下是安装程序的卸载部分 *
  342. ******************************/

  343. Section Uninstall
  344. ;Shortcuts removal fails on Windows Vista
  345. SetShellVarContext all

  346. ;unregister dll
  347. UnRegDLL "$INSTDIR\MSCOMM32.OCX"
  348. Delete "$INSTDIR\MSCOMM32.OCX"

  349. Delete "$INSTDIR\NetFx20SP1_x86.exe"

  350. Delete "$INSTDIR\${PRODUCT_NAME}.url"
  351. Delete "$INSTDIR\uninst.exe"
  352. Delete "$INSTDIR\Hello.exe"
  353. Delete "$INSTDIR\COPYING.txt"

  354. Delete "$SMPROGRAMS\Hello\Uninstall.lnk"
  355. Delete "$SMPROGRAMS\Hello\Website.lnk"
  356. Delete "$DESKTOP\Hello.lnk"
  357. Delete "$SMPROGRAMS\Hello\Hello.lnk"

  358. RMDir "$SMPROGRAMS\Hello"

  359. RMDir "$INSTDIR"

  360. DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  361. DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
  362. SetAutoClose true
  363. SectionEnd

  364. #-- 根据 NSIS 脚本编辑规则,所有 Function 区段必须放置在 Section 区段之后编写,以避免安装程序出现未可预知的问题。--#
  365. Function FuncUninstall
  366. ;卸载当前的版本
  367. ReadRegStr $R1 HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
  368. ClearErrors
  369. ExecWait '$R1 _?=$INSTDIR'
  370. IfErrors no_remove_uninstaller
  371. IfFileExists "$INSTDIR/makensis.exe" no_remove_uninstaller
  372. Delete $R1
  373. RMDir $INSTDIR
  374. no_remove_uninstaller:
  375. FunctionEnd

  376. Function FuncReinstall

  377. ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayVersion"

  378. ${If} $R0 == ""
  379. Abort
  380. ${EndIf}

  381. ${VersionCompare} ${VER_MAJOR}.${VER_MINOR}.${VER_REVISION}.${VER_BUILD} $R0 $R0
  382. ${If} $R0 == 0
  383. MessageBox MB_ICONINFORMATION|MB_YESNO "$(^Name) 已经安装。是否卸载后重新安装?" IDYES StartReinstall1
  384. Abort
  385. StartReinstall1:
  386. Call FuncUninstall
  387. ${ElseIf} $R0 == 1
  388. MessageBox MB_ICONINFORMATION|MB_YESNO "你已经安装了一个老版本。您应该在安装之前先卸载当前的版本。是否继续?" IDYES StartReinstall2
  389. StartReinstall2:
  390. Call FuncUninstall
  391. ${ElseIf} $R0 == 2
  392. MessageBox MB_ICONINFORMATION|MB_YESNO "你已经安装了一个较新的版本。安装旧的版本,最好先卸载当前的版本。是否继续?" IDYES StartReinstall3
  393. StartReinstall3:
  394. Call FuncUninstall
  395. ${Else}
  396. Abort
  397. ${EndIf}
  398. FunctionEnd

  399. Function .onInit
  400. ;创建互斥防止重复运行
  401. System::Call 'kernel32::CreateMutexA(i 0, i 0, t "hello_chs_installer") i .r1 ?e'
  402. Pop $R0
  403. StrCmp $R0 0 +3
  404. MessageBox MB_OK|MB_ICONEXCLAMATION "另一个 NSIS 安装向导正在运行."
  405. Abort

  406. ;检测程序是否已经安装
  407. ReadRegStr $R0 HKLM "${PRODUCT_DIR_REGKEY}" ""
  408. ${If} $R0 == ""
  409. MessageBox MB_ICONINFORMATION|MB_OK "立即开始全新安装 $(^Name)!"
  410. ${else}
  411. Call FuncReinstall
  412. ${EndIf}
  413. FunctionEnd

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

  418. Function un.onUninstSuccess
  419. HideWindow
  420. MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地从您的计算机移除。"
  421. FunctionEnd
复制代码

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-5-1 02:03 , Processed in 0.124139 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表