NSIS——檢測SQL Server安裝版本

來源:互聯網
上載者:User

來自:http://nsis.sourceforge.net/How_to_tell_what_version_of_SQLServer_is_installed

1、代碼如下: Function StrTokExch $R1Exch 1Exch $R0Push $R2Push $R3Push $R4Push $R5 ;R0 fullstring;R1 tokens;R2 len of fullstring;R3 len of tokens;R4 char from string;R5 testchar StrLen $R2 $R0IntOp $R2 $R2 + 1 loop1:IntOp $R2 $R2 - 1IntCmp $R2 0 exit StrCpy $R4 $R0 1 -$R2 StrLen $R3 $R1IntOp $R3 $R3 + 1 loop2:IntOp $R3 $R3 - 1IntCmp $R3 0 loop1 StrCpy $R5 $R1 1 -$R3 StrCmp $R4 $R5 FoundGoto loop2Goto loop1 exit:;Not found!!!StrCpy $R1 ""StrCpy $R0 ""Goto Cleanup Found:StrLen $R3 $R0IntOp $R3 $R3 - $R2StrCpy $R1 $R0 $R3 IntOp $R2 $R2 - 1IntOp $R3 $R3 + 1StrCpy $R0 $R0 $R2 $R3 Cleanup:Pop $R5Pop $R4Pop $R3Pop $R2Exch $R0Exch 1Exch $R1 FunctionEnd;--------------------------------; CheckMinSQLVersion;; Written by Matthew Kershaw (matthew.kershaw@us.didata.com);; For this function the min SQL version must be SQL2kSP2 ...; typically the SQLServer version is located in; HKLM\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion\CurrentVersion; but for SPs, the new version is located in; HKLM\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion\CSDVersion.; For SP2, the value is 8.00.534. If the CSDVersion key does not exist,; no SP has been installed.Function CheckMinSQLVersion ClearErrors ReadRegStr $0 HKLM "SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion" "CurrentVersion"IfErrors SQLServerNotFound SQLServerFound SQLServerFound:ReadRegStr $4 HKLM "SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion" "CSDVersion"IfErrors SPNotFound SPFound SPFound: ;Check the first digit of the version; must be 8StrCpy $0 $4StrCpy $1 $0 1StrCmp $1 "8" SQLServer2000Found SQLServerVersionErrorGoto ExitCheckMinSQLVersion SQLServer2000Found: Push $0Push "."Call StrTok;For an example string of "8.00.194", "8" and "00.194" now on stackPop $2Push "."Call StrTok;"00" and "194" now on stackPop $2Pop $3 IntCmp $3 534 0 SQLServerVersionError 0Push 1Goto ExitCheckMinSQLVersion SQLServerVersionError:MessageBox MB_OK|MB_ICONEXCLAMATION "此產品需要SQLServer的最低版本為 v8.00.534 (SQLServer 2000, SP2);檢測到目前的版本為$0。安裝程式將中止。"Push 0Goto ExitCheckMinSQLVersion SQLServerNotFound:MessageBox MB_OK|MB_ICONEXCLAMATION "安裝程式未能檢測到Microsoft SQLServer,這是必須安裝的。安裝程式將中止。"Push 0Goto ExitCheckMinSQLVersion SPNotFound:MessageBox MB_OK|MB_ICONEXCLAMATION "MicrosfotSQLServer v $0 已安裝。SQLServer 2000 SP2 (or later)必須安裝。安裝程式將中止。"Push 0Goto ExitCheckMinSQLVersion ExitCheckMinSQLVersion: FunctionEnd 2、調用Call CheckMinSQLVersionPop $0IntCmp $0 1 +2Abort
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.