home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 June / Chip_2001-06_cd1.bin / zkuste / vbasic / Data / Utility / MSISDK15.msi / Darice.120 / Binary.ice61.vbs < prev    next >
Text File  |  2000-10-05  |  12KB  |  240 lines

  1.  
  2. Function ICE61()
  3. Const UPGRADE_ATTRIBUTE_DETECTONLY = 2
  4. Const UPGRADE_ATTRIBUTE_MININCLUSIVE = 256
  5. Const UPGRADE_ATTRIBUTE_MAXINCLUSIVE = 512
  6. Const UPGRADE_ATTRIBUTE_ALLINCLUSIVE = 768
  7. Const colUpgradeCode = 1
  8. Const colVersionMin = 2
  9. Const colVersionMax = 3
  10. Const colLanguage = 4
  11. Const colAttributes = 5
  12. Const colRemove = 6
  13. Const colActionProperty = 7
  14. On Error Resume Next
  15.  
  16. ICE61 = 1
  17. 'Give creation data
  18. Set recinfo = installer.createrecord(1)
  19. recinfo.StringData(0) = "ICE61" & Chr(9) & "3" & Chr(9) & "Created 05/03/1999. Last Modified 01/17/2000"
  20. 'Debug.Print recinfo.formattext
  21. Message &H3000000, recinfo
  22.  
  23. 'Give description of test
  24. recinfo.StringData(0) = "ICE61" & Chr(9) & "3" & Chr(9) & "Verifies various elements of the Upgrade table"
  25. 'Debug.Print recinfo.formattext
  26. Message &H3000000, recinfo
  27.  
  28. 'Is there a Upgrade table in the database?
  29. iStat = Database.TablePersistent("Upgrade")
  30. If 1 <> iStat Then
  31.     recinfo.StringData(0) = "ICE61" & Chr(9) & "3" & Chr(9) & "Table: 'Upgrade' missing. This product is not enabled for upgrading so ICE61 is not necessary."
  32.     'Debug.Print recinfo.formattext
  33.     Message &H3000000, recinfo
  34.     ICE61 = 1
  35.     Exit Function
  36. End If
  37.  
  38. 'Is there a Property table in the database?
  39. iStat = Database.TablePersistent("Property")
  40. If 1 <> iStat Then
  41.     recinfo.StringData(0) = "ICE61" & Chr(9) & "2" & Chr(9) & "Table: 'Property' missing. ICE61 cannot continue its validation."
  42.     'Debug.Print recinfo.formattext
  43.     Message &H3000000, recinfo
  44.     ICE61 = 1
  45.     Exit Function
  46. End If
  47.  
  48. 'process Upgrade table
  49. Set View = Database.OpenView("SELECT * FROM `Upgrade`")
  50. View.Execute
  51. Set recinfo = View.Fetch
  52. If recinfo Is Nothing Then
  53.     Set recinfo = installer.createrecord(1)
  54.     recinfo.StringData(0) = "ICE61" & Chr(9) & "3" & Chr(9) & "Table: 'Upgrade' is empty. This database will not upgrade any product."
  55.     'Debug.Print recinfo.formattext
  56.     Message &H3000000, recinfo
  57.     ICE61 = 1
  58.     Exit Function
  59. End If
  60.  
  61. 'verify that all ActionProperty properties are not pre-authored
  62. Set View = Database.OpenView("SELECT * FROM `Upgrade`, `Property` WHERE `ActionProperty`= `Property`")
  63. View.Execute
  64. Set recinfo = View.Fetch
  65. While Not recinfo Is Nothing
  66.     recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Upgrade.ActionProperty [7] cannot be authored in the Property table." _
  67.                     & Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "ActionProperty" & Chr(9) & recinfo.StringData(colUpgradeCode) _
  68.                     & Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
  69.                     & Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
  70.     'Debug.Print recinfo.formattext
  71.     Message &H3000000, recinfo
  72.     ICE61 = 1
  73.     Set recinfo = View.Fetch
  74. Wend
  75.  
  76. 'verify that all ActionProperty properties are Public Properties
  77. Set View = Database.OpenView("SELECT * FROM `Upgrade`")
  78. View.Execute
  79. Set recinfo = View.Fetch
  80. While Not recinfo Is Nothing
  81.     If recinfo.StringData(colActionProperty) <> UCase(recinfo.StringData(colActionProperty)) Then
  82.         recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Upgrade.ActionProperty [7] must not contain lowercase letters." _
  83.                     & Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "ActionProperty" & Chr(9) & recinfo.StringData(colUpgradeCode) _
  84.                     & Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
  85.                     & Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
  86.         'Debug.Print recinfo.formattext
  87.         Message &H3000000, recinfo
  88.         ICE61 = 1
  89.     End If
  90.     Set recinfo = View.Fetch
  91. Wend
  92.  
  93. 'verify that all ActionProperty properties are included in the SecureCustomProperties value
  94. Set View = Database.OpenView("SELECT  `Value` FROM `Property` WHERE `Property`= 'SecureCustomProperties'")
  95. View.Execute
  96. Set recinfo = View.Fetch
  97. If recinfo Is Nothing Then
  98.     sSecureCustomProperties = ""
  99. Else
  100.     sSecureCustomProperties = ";" & recinfo.StringData(1) & ";"
  101. End If
  102. Set View = Database.OpenView("SELECT * FROM `Upgrade`")
  103. View.Execute
  104. Set recinfo = View.Fetch
  105. While Not recinfo Is Nothing
  106. If InStr(sSecureCustomProperties, ";" & recinfo.StringData(colActionProperty) & ";") = 0 Then
  107.     recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Upgrade.ActionProperty [7] must added to the SecureCustomProperties property." _
  108.                     & Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "ActionProperty" & Chr(9) & recinfo.StringData(colUpgradeCode) _
  109.                     & Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
  110.                     & Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
  111.     'Debug.Print recinfo.formattext
  112.     Message &H3000000, recinfo
  113.     ICE61 = 1
  114. End If
  115. Set recinfo = View.Fetch
  116. Wend
  117.  
  118. 'verify that all ActionProperty properties are only used once
  119. Set View = Database.OpenView("SELECT * FROM `Upgrade` ORDER BY `ActionProperty`")
  120. View.Execute
  121. sTestString = ""
  122. Set recinfo = View.Fetch
  123. While Not recinfo Is Nothing
  124.     If sTestString = recinfo.StringData(colActionProperty) Then
  125.         recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Upgrade.ActionProperty [7] may be used in only one record of the Upgrade table." _
  126.                     & Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "ActionProperty" & Chr(9) & recinfo.StringData(colUpgradeCode) _
  127.                     & Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
  128.                     & Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
  129.         'Debug.Print recinfo.formattext
  130.         Message &H3000000, recinfo
  131.         ICE61 = 1
  132.     End If
  133.     sTestString = recinfo.StringData(colActionProperty)
  134.     Set recinfo = View.Fetch
  135. Wend
  136.  
  137. 'verify that all MinVersions are less than MaxVersions
  138. Set View = Database.OpenView("SELECT * FROM `Upgrade`")
  139. View.Execute
  140. Set recinfo = View.Fetch
  141. While Not recinfo Is Nothing
  142.     If Len(recinfo.StringData(colVersionMax)) And Len(recinfo.StringData(colVersionMin)) Then
  143.         If VersionStringToLong(recinfo.StringData(colVersionMax)) < VersionStringToLong(recinfo.StringData(colVersionMin)) Then
  144.             recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Upgrade.VersionMax cannot be less than Upgrade.VersionMin. ([7])" _
  145.                     & Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "VersionMin" & Chr(9) & recinfo.StringData(colUpgradeCode) _
  146.                     & Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
  147.                     & Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
  148.             'Debug.Print recinfo.formattext
  149.             Message &H3000000, recinfo
  150.             ICE61 = 1
  151.         ElseIf (VersionStringToLong(recinfo.StringData(colVersionMax)) = VersionStringToLong(recinfo.StringData(colVersionMin))) AND Not ((recinfo.integerdata(colAttributes) And UPGRADE_ATTRIBUTE_ALLINCLUSIVE) = UPGRADE_ATTRIBUTE_ALLINCLUSIVE) Then
  152.             recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Upgrade.VersionMax cannot be equal to Upgrade.VersionMin unless both Min and Max are inclusive, otherwise no version will match. ([7])" _
  153.                     & Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "VersionMin" & Chr(9) & recinfo.StringData(colUpgradeCode) _
  154.                     & Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
  155.                     & Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
  156.             'Debug.Print recinfo.formattext
  157.             Message &H3000000, recinfo
  158.             ICE61 = 1        
  159.         End If        
  160.      End If
  161.     Set recinfo = View.Fetch
  162. Wend
  163.  
  164. 'verify that no attempt is made to uninstall a newer product
  165. sUC = "": sPV = "": lPV = 0
  166. Set View = Database.OpenView("SELECT  `Value` FROM `Property` WHERE `Property`= 'UpgradeCode'")
  167. View.Execute
  168. Set recinfo = View.Fetch
  169. If recinfo Is Nothing Then
  170.     recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Property: An UpgradeCode must be authored in the Property table." _
  171.             & Chr(9) & Chr(9) & "Property" & Chr(9) & "Value" & Chr(9) & "UpgradeCode"
  172.     'Debug.Print recinfo.formattext
  173.     Message &H3000000, recinfo
  174.     ICE61 = 1
  175. Else
  176.     sUC = recinfo.StringData(1)
  177. End If
  178. Set View = Database.OpenView("SELECT  `Value` FROM `Property` WHERE `Property`= 'ProductVersion'")
  179. View.Execute
  180. Set recinfo = View.Fetch
  181. If recinfo Is Nothing Then
  182.     recinfo.StringData(0) = "ICE61" & Chr(9) & "1" & Chr(9) & "Property: A ProductVersion must be authored in the Property table." _
  183.             & Chr(9) & Chr(9) & "Property" & Chr(9) & "Value" & Chr(9) & "ProductVersion"
  184.     'Debug.Print recinfo.formattext
  185.     Message &H3000000, recinfo
  186.     ICE61 = 1
  187. Else
  188.     sPV = recinfo.StringData(1): lPV = VersionStringToLong(sPV)
  189. End If
  190. Set View = Database.OpenView("SELECT * FROM `Upgrade` WHERE `UpgradeCode`= '" & sUC & "'")
  191. View.Execute
  192. Set recinfo = View.Fetch
  193. While Not recinfo Is Nothing
  194.     If Not ((recinfo.integerdata(colAttributes) And UPGRADE_ATTRIBUTE_DETECTONLY) = UPGRADE_ATTRIBUTE_DETECTONLY) Then
  195.         If Len(recinfo.StringData(colVersionMax)) Then
  196.             If (((recinfo.integerdata(colAttributes) And UPGRADE_ATTRIBUTE_MAXINCLUSIVE) And VersionStringToLong(recinfo.StringData(colVersionMax)) >= lPV) Or ((Not (recinfo.integerdata(colAttributes) And UPGRADE_ATTRIBUTE_MAXINCLUSIVE) And VersionStringToLong(recinfo.StringData(colVersionMax)) > lPV))) Then
  197.                 recinfo.StringData(0) = "ICE61" & Chr(9) & "2" & Chr(9) & "This product should remove only older versions of itself. The Maximum version is not less than the current product. ([3] " & sPV & ")" _
  198.                         & Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "Attributes" & Chr(9) & recinfo.StringData(colUpgradeCode) _
  199.                         & Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
  200.                         & Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
  201.                 'Debug.Print recinfo.formattext
  202.                 Message &H3000000, recinfo
  203.                 ICE61 = 1
  204.             End If
  205.         Else
  206.             recinfo.StringData(0) = "ICE61" & Chr(9) & "2" & Chr(9) & "This product should remove only older versions of itself. No Maximum version was detected for the current product. ([7])" _
  207.                     & Chr(9) & Chr(9) & "Upgrade" & Chr(9) & "Attributes" & Chr(9) & recinfo.StringData(colUpgradeCode) _
  208.                     & Chr(9) & recinfo.StringData(colVersionMin) & Chr(9) & recinfo.StringData(colVersionMax) _
  209.                     & Chr(9) & recinfo.StringData(colLanguage) & Chr(9) & recinfo.StringData(colAttributes)
  210.             'Debug.Print recinfo.formattext
  211.             Message &H3000000, recinfo
  212.             ICE61 = 1
  213.         End If
  214.     End If
  215.     
  216.     Set recinfo = View.Fetch
  217. Wend
  218.  
  219. End Function
  220.  
  221. Function VersionStringToLong(strng)
  222. Dim i, iPos, sAccum, sTemp
  223. On Error Resume Next
  224.   sTemp = strng
  225.   iPos = InStr(sTemp & ".", ".")
  226.   sAccum = "&H" & Right("00" & Hex(CInt(Left(sTemp, iPos - 1))), 2)
  227.   If Err.Number > 0 Then VersionStringToLong = 0: Exit Function
  228.   sTemp = Mid(sTemp & ".", iPos + 1)
  229.   iPos = InStr(sTemp & ".", ".")
  230.   sAccum = sAccum & Right("00" & Hex(CInt(Left(sTemp, iPos - 1))), 2)
  231.   If Err.Number > 0 Then VersionStringToLong = 0: Exit Function
  232.   sTemp = Mid(sTemp & ".", iPos + 1)
  233.   iPos = InStr(sTemp & ".", ".")
  234.   sAccum = sAccum & Right("0000" & Hex(CInt(Left(sTemp, iPos - 1))), 4)
  235.   If Err.Number > 0 Then VersionStringToLong = 0: Exit Function
  236.   VersionStringToLong = CLng(sAccum)
  237.   Exit Function
  238. End Function
  239.  
  240.