杉宫竹苑工作室

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

检测SQL Server安装版本

[复制链接]
发表于 2016-9-2 19:55:58 | 显示全部楼层 |阅读模式

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

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

x
1、代码如下:

  1. Function StrTok
  2. Exch $R1
  3. Exch 1
  4. Exch $R0
  5. Push $R2
  6. Push $R3
  7. Push $R4
  8. Push $R5

  9. ;R0 fullstring
  10. ;R1 tokens
  11. ;R2 len of fullstring
  12. ;R3 len of tokens
  13. ;R4 char from string
  14. ;R5 testchar

  15. StrLen $R2 $R0
  16. IntOp $R2 $R2 + 1

  17. loop1:
  18. IntOp $R2 $R2 - 1
  19. IntCmp $R2 0 exit

  20. StrCpy $R4 $R0 1 -$R2

  21. StrLen $R3 $R1
  22. IntOp $R3 $R3 + 1

  23. loop2:
  24. IntOp $R3 $R3 - 1
  25. IntCmp $R3 0 loop1

  26. StrCpy $R5 $R1 1 -$R3

  27. StrCmp $R4 $R5 Found
  28. Goto loop2
  29. Goto loop1

  30. exit:
  31. ;Not found!!!
  32. StrCpy $R1 ""
  33. StrCpy $R0 ""
  34. Goto Cleanup

  35. Found:
  36. StrLen $R3 $R0
  37. IntOp $R3 $R3 - $R2
  38. StrCpy $R1 $R0 $R3

  39. IntOp $R2 $R2 - 1
  40. IntOp $R3 $R3 + 1
  41. StrCpy $R0 $R0 $R2 $R3

  42. Cleanup:
  43. Pop $R5
  44. Pop $R4
  45. Pop $R3
  46. Pop $R2
  47. Exch $R0
  48. Exch 1
  49. Exch $R1

  50. FunctionEnd
  51. ;--------------------------------
  52. ; CheckMinSQLVersion
  53. ;
  54. ; Written by Matthew Kershaw (matthew.kershaw@us.didata.com)
  55. ;
  56. ; For this function the min SQL version must be SQL2kSP2 ...
  57. ; typically the SQLServer version is located in
  58. ; HKLM\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion\CurrentVersion
  59. ; but for SPs, the new version is located in
  60. ; HKLM\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion\CSDVersion.
  61. ; For SP2, the value is 8.00.534. If the CSDVersion key does not exist,
  62. ; no SP has been installed.
  63. Function CheckMinSQLVersion

  64. ClearErrors

  65. ReadRegStr $0 HKLM "SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion" "CurrentVersion"
  66. IfErrors SQLServerNotFound SQLServerFound

  67. SQLServerFound:
  68. ReadRegStr $4 HKLM "SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion" "CSDVersion"
  69. IfErrors SPNotFound SPFound

  70. SPFound:

  71. ;Check the first digit of the version; must be 8
  72. StrCpy $0 $4
  73. StrCpy $1 $0 1
  74. StrCmp $1 "8" SQLServer2000Found SQLServerVersionError
  75. Goto ExitCheckMinSQLVersion

  76. SQLServer2000Found:

  77. Push $0
  78. Push "."
  79. Call StrTok;For an example string of "8.00.194", "8" and "00.194" now on stack
  80. Pop $2
  81. Push "."
  82. Call StrTok;"00" and "194" now on stack
  83. Pop $2
  84. Pop $3

  85. IntCmp $3 534 0 SQLServerVersionError 0
  86. Push 1
  87. Goto ExitCheckMinSQLVersion

  88. SQLServerVersionError:
  89. MessageBox MB_OK|MB_ICONEXCLAMATION "此产品需要SQLServer的最低版本为 v8.00.534 (SQLServer 2000, SP2);检测到当前版本为$0。安装程序将中止。"
  90. Push 0
  91. Goto ExitCheckMinSQLVersion

  92. SQLServerNotFound:
  93. MessageBox MB_OK|MB_ICONEXCLAMATION "安装程序未能检测到Microsoft SQLServer,这是必须安装的。安装程序将中止。"
  94. Push 0
  95. Goto ExitCheckMinSQLVersion

  96. SPNotFound:
  97. MessageBox MB_OK|MB_ICONEXCLAMATION "MicrosfotSQLServer v $0 已安装。SQLServer 2000 SP2 (or later)必须安装。安装程序将中止。"
  98. Push 0
  99. Goto ExitCheckMinSQLVersion

  100. ExitCheckMinSQLVersion:

  101. FunctionEnd
复制代码


2、调用
  1. Call CheckMinSQLVersion
  2. Pop $0
  3. IntCmp $0 1 +2
  4. Abort
复制代码
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-18 01:58 , Processed in 0.117632 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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