ArchitectureSpecificRegistry.vbs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. ' Notes: wanted to implement this using a class but:
  2. ' 1. No matter what I did I could not assign the result of GetObject to a private member
  3. ' 2. It looks as if all methods were treated as subs from the outside world which is not good since
  4. ' some of these need to return a value
  5. ' should be removed when migration is complete
  6. Set private_oReg = GetObject("winmgmts:\root\default:StdRegProv")
  7. Set private_oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
  8. private_oCtx.Add "__ProviderArchitecture", CInt(OSArchitecture)
  9. Set private_oLocator = CreateObject("Wbemscripting.SWbemLocator")
  10. Set private_oServices = private_oLocator.ConnectServer(".", "root\default","","",,,,private_oCtx)
  11. Set private_oRegSpecific = private_oServices.Get("StdRegProv")
  12. Function CheckAccess(hDefKey,sSubKeyName,uRequired, bGranted )
  13. Set Inparams = private_oRegSpecific.Methods_("CheckAccess").Inparameters
  14. Inparams.hDefKey = hDefKey
  15. Inparams.sSubKeyName = sSubKeyName
  16. Inparams.uRequired = uRequired
  17. set Outparams = private_oRegSpecific.ExecMethod_("CheckAccess", Inparams,,private_oCtx)
  18. bGranted = Outparams.bGranted
  19. CheckAccess = 0
  20. End Function
  21. Function CreateKey(hDefKey,sSubKeyName)
  22. Set Inparams = private_oRegSpecific.Methods_("CreateKey").Inparameters
  23. Inparams.hDefKey = hDefKey
  24. Inparams.sSubKeyName = sSubKeyName
  25. set Outparams = private_oRegSpecific.ExecMethod_("CreateKey", Inparams,,private_oCtx)
  26. CreateKey = 0
  27. End Function
  28. Function DeleteKey(hDefKey,sSubKeyName)
  29. Set Inparams = private_oRegSpecific.Methods_("DeleteKey").Inparameters
  30. Inparams.hDefKey = hDefKey
  31. Inparams.sSubKeyName = sSubKeyName
  32. set Outparams = private_oRegSpecific.ExecMethod_("DeleteKey", Inparams,,private_oCtx)
  33. DeleteKey = 0
  34. End Function
  35. Function DeleteValue(hDefKey,sSubKeyName,sValueName)
  36. Set Inparams = private_oRegSpecific.Methods_("DeleteValue").Inparameters
  37. Inparams.hDefKey = hDefKey
  38. Inparams.sSubKeyName = sSubKeyName
  39. Inparams.sValueName = sValueName
  40. set Outparams = private_oRegSpecific.ExecMethod_("DeleteValue", Inparams,,private_oCtx)
  41. DeleteValue = 0
  42. End Function
  43. Function EnumKey(hDefKey,sSubKeyName, sNames )
  44. Set Inparams = private_oRegSpecific.Methods_("EnumKey").Inparameters
  45. Inparams.hDefKey = hDefKey
  46. Inparams.sSubKeyName = sSubKeyName
  47. set Outparams = private_oRegSpecific.ExecMethod_("EnumKey", Inparams,,private_oCtx)
  48. sNames = Outparams.sNames
  49. EnumKey = 0
  50. End Function
  51. Function EnumValues(hDefKey,sSubKeyName, sNames,Types )
  52. Set Inparams = private_oRegSpecific.Methods_("EnumValues").Inparameters
  53. Inparams.hDefKey = hDefKey
  54. Inparams.sSubKeyName = sSubKeyName
  55. set Outparams = private_oRegSpecific.ExecMethod_("EnumValues", Inparams,,private_oCtx)
  56. sNames = Outparams.sNames
  57. Types = Outparams.Types
  58. EnumValues = 0
  59. End Function
  60. Function GetBinaryValue(hDefKey,sSubKeyName,sValueName, uValue )
  61. Set Inparams = private_oRegSpecific.Methods_("GetBinaryValue").Inparameters
  62. Inparams.hDefKey = hDefKey
  63. Inparams.sSubKeyName = sSubKeyName
  64. Inparams.sValueName = sValueName
  65. set Outparams = private_oRegSpecific.ExecMethod_("GetBinaryValue", Inparams,,private_oCtx)
  66. uValue = Outparams.uValue
  67. GetBinaryValue = 0
  68. End Function
  69. Function GetDWORDValue(hDefKey,sSubKeyName,sValueName, uValue )
  70. Set Inparams = private_oRegSpecific.Methods_("GetDWORDValue").Inparameters
  71. Inparams.hDefKey = hDefKey
  72. Inparams.sSubKeyName = sSubKeyName
  73. Inparams.sValueName = sValueName
  74. set Outparams = private_oRegSpecific.ExecMethod_("GetDWORDValue", Inparams,,private_oCtx)
  75. uValue = Outparams.uValue
  76. GetDWORDValue = 0
  77. End Function
  78. Function GetExpandedStringValue(hDefKey,sSubKeyName,sValueName, sValue )
  79. Set Inparams = private_oRegSpecific.Methods_("GetExpandedStringValue").Inparameters
  80. Inparams.hDefKey = hDefKey
  81. Inparams.sSubKeyName = sSubKeyName
  82. Inparams.sValueName = sValueName
  83. set Outparams = private_oRegSpecific.ExecMethod_("GetExpandedStringValue", Inparams,,private_oCtx)
  84. sValue = Outparams.sValue
  85. GetExpandedStringValue = 0
  86. End Function
  87. Function GetMultiStringValue(hDefKey,sSubKeyName,sValueName, sValue )
  88. Set Inparams = private_oRegSpecific.Methods_("GetMultiStringValue").Inparameters
  89. Inparams.hDefKey = hDefKey
  90. Inparams.sSubKeyName = sSubKeyName
  91. Inparams.sValueName = sValueName
  92. set Outparams = private_oRegSpecific.ExecMethod_("GetMultiStringValue", Inparams,,private_oCtx)
  93. sValue = Outparams.sValue
  94. GetMultiStringValue = 0
  95. End Function
  96. Function GetQWORDValue(hDefKey,sSubKeyName,sValueName, uValue )
  97. Set Inparams = private_oRegSpecific.Methods_("GetQWORDValue").Inparameters
  98. Inparams.hDefKey = hDefKey
  99. Inparams.sSubKeyName = sSubKeyName
  100. Inparams.sValueName = sValueName
  101. set Outparams = private_oRegSpecific.ExecMethod_("GetQWORDValue", Inparams,,private_oCtx)
  102. uValue = Outparams.uValue
  103. GetQWORDValue = 0
  104. End Function
  105. Function GetSecurityDescriptor(hDefKey,sSubKeyName, Descriptor )
  106. Set Inparams = private_oRegSpecific.Methods_("GetSecurityDescriptor").Inparameters
  107. Inparams.hDefKey = hDefKey
  108. Inparams.sSubKeyName = sSubKeyName
  109. set Outparams = private_oRegSpecific.ExecMethod_("GetSecurityDescriptor", Inparams,,private_oCtx)
  110. Descriptor = Outparams.Descriptor
  111. GetSecurityDescriptor = 0
  112. End Function
  113. Function GetStringValue(hDefKey,sSubKeyName,sValueName, sValue )
  114. Set Inparams = private_oRegSpecific.Methods_("GetStringValue").Inparameters
  115. Inparams.hDefKey = hDefKey
  116. Inparams.sSubKeyName = sSubKeyName
  117. Inparams.sValueName = sValueName
  118. set Outparams = private_oRegSpecific.ExecMethod_("GetStringValue", Inparams,,private_oCtx)
  119. sValue = Outparams.sValue
  120. GetStringValue = 0
  121. End Function
  122. Function SetBinaryValue(hDefKey,sSubKeyName,sValueName,uValue)
  123. Set Inparams = private_oRegSpecific.Methods_("SetBinaryValue").Inparameters
  124. Inparams.hDefKey = hDefKey
  125. Inparams.sSubKeyName = sSubKeyName
  126. Inparams.sValueName = sValueName
  127. Inparams.uValue = uValue
  128. set Outparams = private_oRegSpecific.ExecMethod_("SetBinaryValue", Inparams,,private_oCtx)
  129. SetBinaryValue = 0
  130. End Function
  131. Function SetDWORDValue(hDefKey,sSubKeyName,sValueName,uValue)
  132. Set Inparams = private_oRegSpecific.Methods_("SetDWORDValue").Inparameters
  133. Inparams.hDefKey = hDefKey
  134. Inparams.sSubKeyName = sSubKeyName
  135. Inparams.sValueName = sValueName
  136. Inparams.uValue = uValue
  137. set Outparams = private_oRegSpecific.ExecMethod_("SetDWORDValue", Inparams,,private_oCtx)
  138. SetDWORDValue = 0
  139. End Function
  140. Function SetExpandedStringValue(hDefKey,sSubKeyName,sValueName,sValue)
  141. Set Inparams = private_oRegSpecific.Methods_("SetExpandedStringValue").Inparameters
  142. Inparams.hDefKey = hDefKey
  143. Inparams.sSubKeyName = sSubKeyName
  144. Inparams.sValueName = sValueName
  145. Inparams.sValue = sValue
  146. set Outparams = private_oRegSpecific.ExecMethod_("SetExpandedStringValue", Inparams,,private_oCtx)
  147. SetExpandedStringValue = 0
  148. End Function
  149. Function SetMultiStringValue(hDefKey,sSubKeyName,sValueName,sValue)
  150. Set Inparams = private_oRegSpecific.Methods_("SetMultiStringValue").Inparameters
  151. Inparams.hDefKey = hDefKey
  152. Inparams.sSubKeyName = sSubKeyName
  153. Inparams.sValueName = sValueName
  154. Inparams.sValue = sValue
  155. set Outparams = private_oRegSpecific.ExecMethod_("SetMultiStringValue", Inparams,,private_oCtx)
  156. SetMultiStringValue = 0
  157. End Function
  158. Function SetQWORDValue(hDefKey,sSubKeyName,sValueName,uValue)
  159. Set Inparams = private_oRegSpecific.Methods_("SetQWORDValue").Inparameters
  160. Inparams.hDefKey = hDefKey
  161. Inparams.sSubKeyName = sSubKeyName
  162. Inparams.sValueName = sValueName
  163. Inparams.uValue = uValue
  164. set Outparams = private_oRegSpecific.ExecMethod_("SetQWORDValue", Inparams,,private_oCtx)
  165. SetQWORDValue = 0
  166. End Function
  167. Function SetSecurityDescriptor(hDefKey,sSubKeyName,Descriptor)
  168. Set Inparams = private_oRegSpecific.Methods_("SetSecurityDescriptor").Inparameters
  169. Inparams.hDefKey = hDefKey
  170. Inparams.sSubKeyName = sSubKeyName
  171. Inparams.Descriptor = Descriptor
  172. set Outparams = private_oRegSpecific.ExecMethod_("SetSecurityDescriptor", Inparams,,private_oCtx)
  173. SetSecurityDescriptor = 0
  174. End Function
  175. Function SetStringValue(hDefKey,sSubKeyName,sValueName,sValue)
  176. Set Inparams = private_oRegSpecific.Methods_("SetStringValue").Inparameters
  177. Inparams.hDefKey = hDefKey
  178. Inparams.sSubKeyName = sSubKeyName
  179. Inparams.sValueName = sValueName
  180. Inparams.sValue = sValue
  181. set Outparams = private_oRegSpecific.ExecMethod_("SetStringValue", Inparams,,private_oCtx)
  182. SetStringValue = 0
  183. End Function