|
Function KeyExists(ByVal Resource, ByVal hDefKey, ByVal sSubKeyName, ByVal ProviderArchitecture)
|
|
Const wbemAuthenticationLevelPktPrivacy = 6
|
|
Const wbemImpersonationLevelImpersonate = 3
|
|
Dim oCtx: Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
|
|
oCtx.Add "__ProviderArchitecture", ProviderArchitecture
|
|
oCtx.Add "__RequiredArchitecture", True
|
|
Dim oLocator: Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
|
|
oLocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
|
|
oLocator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
|
|
Dim oReg: Set oReg = oLocator.ConnectServer(Resource, "root\default", "", "", , , , oCtx).Get("StdRegProv")
|
|
Dim oInParams: Set oInParams = oReg.Methods_("EnumKey").InParameters
|
|
oInParams.hDefKey = hDefKey
|
|
oInParams.sSubKeyName = sSubKeyName
|
|
Dim oOutParams: Set oOutParams = oReg.ExecMethod_("EnumKey", oInParams, , oCtx)
|
|
If oOutParams.ReturnValue = 0 Then
|
|
KeyExists = 1
|
|
Else
|
|
KeyExists = 0
|
|
End If
|
|
End Function
|
|
|
|
Function KeyEmpty(ByVal Resource, ByVal hDefKey, ByVal sSubKeyName, ByVal ProviderArchitecture)
|
|
Const wbemAuthenticationLevelPktPrivacy = 6
|
|
Const wbemImpersonationLevelImpersonate = 3
|
|
Dim oCtx: Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
|
|
oCtx.Add "__ProviderArchitecture", ProviderArchitecture
|
|
oCtx.Add "__RequiredArchitecture", True
|
|
Dim oLocator: Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
|
|
oLocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
|
|
oLocator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
|
|
Dim oReg: Set oReg = oLocator.ConnectServer(Resource, "root\default", "", "", , , , oCtx).Get("StdRegProv")
|
|
|
|
Dim subitemCount: subitemCount = 0
|
|
Dim sValueName: sValueName = ""
|
|
Dim oInParams, oOutParams
|
|
|
|
' EnumKey (no subkeys)
|
|
Set oInParams = oReg.Methods_("EnumKey").InParameters
|
|
oInParams.hDefKey = hDefKey
|
|
oInParams.sSubKeyName = sSubKeyName
|
|
Set oOutParams = oReg.ExecMethod_("EnumKey", oInParams, , oCtx)
|
|
If oOutParams.ReturnValue = 0 Then
|
|
If Not IsNull(oOutParams.sNames) Then
|
|
subitemCount = subitemCount + UBound(oOutParams.sNames) + 1
|
|
End If
|
|
End If
|
|
|
|
' EnumValues (no values)
|
|
Set oInParams = oReg.Methods_("EnumValues").InParameters
|
|
oInParams.hDefKey = hDefKey
|
|
oInParams.sSubKeyName = sSubKeyName
|
|
Set oOutParams = oReg.ExecMethod_("EnumValues", oInParams, , oCtx)
|
|
If oOutParams.ReturnValue = 0 Then
|
|
If Not IsNull(oOutParams.sNames) Then
|
|
subitemCount = subitemCount + UBound(oOutParams.sNames) + 1
|
|
End If
|
|
End If
|
|
|
|
' GetStringValue (no default value)
|
|
Set oInParams = oReg.Methods_("GetStringValue").InParameters
|
|
oInParams.hDefKey = hDefKey
|
|
oInParams.sSubKeyName = sSubKeyName
|
|
oInParams.sValueName = sValueName
|
|
Set oOutParams = oReg.ExecMethod_("GetStringValue", oInParams, , oCtx)
|
|
If oOutParams.ReturnValue = 0 Then
|
|
If Not IsNull(oOutParams.sValue) Then
|
|
subitemCount = subitemCount + 1
|
|
End If
|
|
End If
|
|
|
|
if subitemCount = 0 Then
|
|
KeyEmpty = 1
|
|
Else
|
|
KeyEmpty = 0
|
|
End If
|
|
|
|
End Function
|
|
|
|
Function GetDWordValue (ByVal Resource, ByVal hDefKey, ByVal sSubKeyName, ByVal sValueName, ByVal ProviderArchitecture)
|
|
Const wbemAuthenticationLevelPktPrivacy = 6
|
|
Const wbemImpersonationLevelImpersonate = 3
|
|
Dim oCtx: Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
|
|
oCtx.Add "__ProviderArchitecture", ProviderArchitecture
|
|
oCtx.Add "__RequiredArchitecture", True
|
|
Dim oLocator: Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
|
|
oLocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
|
|
oLocator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
|
|
Dim oReg: Set oReg = oLocator.ConnectServer(Resource, "root\default", "", "", , , , oCtx).Get("StdRegProv")
|
|
Dim oInParams: Set oInParams = oReg.Methods_("GetDWORDValue").InParameters
|
|
oInParams.hDefKey = hDefKey
|
|
oInParams.sSubKeyName = sSubKeyName
|
|
oInParams.sValueName = sValueName
|
|
Dim oOutParams: Set oOutParams = oReg.ExecMethod_("GetDWORDValue", oInParams, , oCtx)
|
|
If oOutParams.ReturnValue = 0 Then GetDWordValue = oOutParams.uValue
|
|
End Function
|
|
|
|
Function GetStringValue (ByVal Resource, ByVal hDefKey, ByVal sSubKeyName, ByVal sValueName, ByVal ProviderArchitecture)
|
|
Const wbemAuthenticationLevelPktPrivacy = 6
|
|
Const wbemImpersonationLevelImpersonate = 3
|
|
Dim oCtx: Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
|
|
oCtx.Add "__ProviderArchitecture", ProviderArchitecture
|
|
oCtx.Add "__RequiredArchitecture", True
|
|
Dim oLocator: Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
|
|
oLocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
|
|
oLocator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
|
|
Dim oReg: Set oReg = oLocator.ConnectServer(Resource, "root\default", "", "", , , , oCtx).Get("StdRegProv")
|
|
Dim oInParams: Set oInParams = oReg.Methods_("GetStringValue").InParameters
|
|
oInParams.hDefKey = hDefKey
|
|
oInParams.sSubKeyName = sSubKeyName
|
|
oInParams.sValueName = sValueName
|
|
Dim oOutParams: Set oOutParams = oReg.ExecMethod_("GetStringValue", oInParams, , oCtx)
|
|
If oOutParams.ReturnValue = 0 Then GetStringValue = oOutParams.sValue
|
|
End Function
|
|
|
|
Function SetDWordValue (ByVal Resource, ByVal hDefKey, ByVal sSubKeyName, ByVal sValueName, ByVal uValue, ByVal ProviderArchitecture)
|
|
Const wbemAuthenticationLevelPktPrivacy = 6
|
|
Const wbemImpersonationLevelImpersonate = 3
|
|
Dim oCtx: Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
|
|
oCtx.Add "__ProviderArchitecture", ProviderArchitecture
|
|
oCtx.Add "__RequiredArchitecture", True
|
|
Dim oLocator: Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
|
|
oLocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
|
|
oLocator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
|
|
Dim oReg: Set oReg = oLocator.ConnectServer(Resource, "root\default", "", "", , , , oCtx).Get("StdRegProv")
|
|
Dim oInParams: Set oInParams = oReg.Methods_("SetDWordValue").InParameters
|
|
oInParams.hDefKey = hDefKey
|
|
oInParams.sSubKeyName = sSubKeyName
|
|
oInParams.sValueName = sValueName
|
|
oInParams.uValue = uValue
|
|
Dim oOutParams: Set oOutParams = oReg.ExecMethod_("SetDWordValue", oInParams, , oCtx)
|
|
SetDWordValue = oOutParams.ReturnValue
|
|
End Function
|
|
|
|
Function SetStringValue (ByVal Resource, ByVal hDefKey, ByVal sSubKeyName, ByVal sValueName, ByVal sValue, ByVal ProviderArchitecture)
|
|
Const wbemAuthenticationLevelPktPrivacy = 6
|
|
Const wbemImpersonationLevelImpersonate = 3
|
|
Dim oCtx: Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
|
|
oCtx.Add "__ProviderArchitecture", ProviderArchitecture
|
|
oCtx.Add "__RequiredArchitecture", True
|
|
Dim oLocator: Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
|
|
oLocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
|
|
oLocator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
|
|
Dim oReg: Set oReg = oLocator.ConnectServer(Resource, "root\default", "", "", , , , oCtx).Get("StdRegProv")
|
|
Dim oInParams: Set oInParams = oReg.Methods_("SetStringValue").InParameters
|
|
oInParams.hDefKey = hDefKey
|
|
oInParams.sSubKeyName = sSubKeyName
|
|
oInParams.sValueName = sValueName
|
|
oInParams.sValue = sValue
|
|
Dim oOutParams: Set oOutParams = oReg.ExecMethod_("SetStringValue", oInParams, , oCtx)
|
|
SetStringValue = oOutParams.ReturnValue
|
|
End Function
|
|
|
|
Function SetMultiStringValue (ByVal Resource, ByVal hDefKey, ByVal sSubKeyName, ByVal sValueName, ByVal sValue, ByVal ProviderArchitecture)
|
|
Const wbemAuthenticationLevelPktPrivacy = 6
|
|
Const wbemImpersonationLevelImpersonate = 3
|
|
Dim oCtx: Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
|
|
oCtx.Add "__ProviderArchitecture", ProviderArchitecture
|
|
oCtx.Add "__RequiredArchitecture", True
|
|
Dim oLocator: Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
|
|
oLocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
|
|
oLocator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
|
|
Dim oReg: Set oReg = oLocator.ConnectServer(Resource, "root\default", "", "", , , , oCtx).Get("StdRegProv")
|
|
Dim oInParams: Set oInParams = oReg.Methods_("SetMultiStringValue").InParameters
|
|
oInParams.hDefKey = hDefKey
|
|
oInParams.sSubKeyName = sSubKeyName
|
|
oInParams.sValueName = sValueName
|
|
oInParams.sValue = sValue
|
|
Dim oOutParams: Set oOutParams = oReg.ExecMethod_("SetMultiStringValue", oInParams, , oCtx)
|
|
SetMultiStringValue = oOutParams.ReturnValue
|
|
End Function
|
|
|
|
Function CreateKey (ByVal Resource, ByVal hDefKey, ByVal sSubKeyName, ByVal ProviderArchitecture)
|
|
Const wbemAuthenticationLevelPktPrivacy = 6
|
|
Const wbemImpersonationLevelImpersonate = 3
|
|
Dim oCtx: Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
|
|
oCtx.Add "__ProviderArchitecture", ProviderArchitecture
|
|
oCtx.Add "__RequiredArchitecture", True
|
|
Dim oLocator: Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
|
|
oLocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
|
|
oLocator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
|
|
Dim oReg: Set oReg = oLocator.ConnectServer(Resource, "root\default", "", "", , , , oCtx).Get("StdRegProv")
|
|
Dim oInParams: Set oInParams = oReg.Methods_("CreateKey").InParameters
|
|
oInParams.hDefKey = hDefKey
|
|
oInParams.sSubKeyName = sSubKeyName
|
|
Dim oOutParams: Set oOutParams = oReg.ExecMethod_("CreateKey", oInParams, , oCtx)
|
|
CreateKey = oOutParams.ReturnValue
|
|
End Function
|
|
|
|
Function DeleteValue (ByVal Resource, ByVal hDefKey, ByVal sSubKeyName, ByVal sValueName, ByVal ProviderArchitecture)
|
|
Const wbemAuthenticationLevelPktPrivacy = 6
|
|
Const wbemImpersonationLevelImpersonate = 3
|
|
Dim oCtx: Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
|
|
oCtx.Add "__ProviderArchitecture", ProviderArchitecture
|
|
oCtx.Add "__RequiredArchitecture", True
|
|
Dim oLocator: Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
|
|
oLocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
|
|
oLocator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
|
|
Dim oReg: Set oReg = oLocator.ConnectServer(Resource, "root\default", "", "", , , , oCtx).Get("StdRegProv")
|
|
Dim oInParams: Set oInParams = oReg.Methods_("DeleteValue").InParameters
|
|
oInParams.hDefKey = hDefKey
|
|
oInParams.sSubKeyName = sSubKeyName
|
|
oInParams.sValueName = sValueName
|
|
Dim oOutParams: Set oOutParams = oReg.ExecMethod_("DeleteValue", oInParams, , oCtx)
|
|
DeleteValue = oOutParams.ReturnValue
|
|
End Function
|
|
|
|
Function DeleteKey (ByVal Resource, ByVal hDefKey, ByVal sSubKeyName, ByVal ProviderArchitecture)
|
|
Const wbemAuthenticationLevelPktPrivacy = 6
|
|
Const wbemImpersonationLevelImpersonate = 3
|
|
Dim oCtx: Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
|
|
oCtx.Add "__ProviderArchitecture", ProviderArchitecture
|
|
oCtx.Add "__RequiredArchitecture", True
|
|
Dim oLocator: Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
|
|
oLocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
|
|
oLocator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
|
|
Dim oReg: Set oReg = oLocator.ConnectServer(Resource, "root\default", "", "", , , , oCtx).Get("StdRegProv")
|
|
Dim oInParams: Set oInParams = oReg.Methods_("DeleteKey").InParameters
|
|
oInParams.hDefKey = hDefKey
|
|
oInParams.sSubKeyName = sSubKeyName
|
|
Dim oOutParams: Set oOutParams = oReg.ExecMethod_("DeleteKey", oInParams, , oCtx)
|
|
DeleteKey = oOutParams.ReturnValue
|
|
End Function
|
|
|
|
Function EnumValues (ByVal Resource, ByVal hDefKey, ByVal sSubKeyName, ByVal ProviderArchitecture)
|
|
Const wbemAuthenticationLevelPktPrivacy = 6
|
|
Const wbemImpersonationLevelImpersonate = 3
|
|
Dim oCtx: Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
|
|
oCtx.Add "__ProviderArchitecture", ProviderArchitecture
|
|
oCtx.Add "__RequiredArchitecture", True
|
|
Dim oLocator: Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
|
|
oLocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
|
|
oLocator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
|
|
Dim oReg: Set oReg = oLocator.ConnectServer(Resource, "root\default", "", "", , , , oCtx).Get("StdRegProv")
|
|
Dim oInParams: Set oInParams = oReg.Methods_("EnumValues").InParameters
|
|
oInParams.hDefKey = hDefKey
|
|
oInParams.sSubKeyName = sSubKeyName
|
|
Dim oOutParams: Set oOutParams = oReg.ExecMethod_("EnumValues", oInParams, , oCtx)
|
|
If oOutParams.ReturnValue = 0 Then Set EnumValues = oOutParams
|
|
End Function
|
|
|
|
Function EnumKey (ByVal Resource, ByVal hDefKey, ByVal sSubKeyName, ByVal ProviderArchitecture)
|
|
Const wbemAuthenticationLevelPktPrivacy = 6
|
|
Const wbemImpersonationLevelImpersonate = 3
|
|
Dim oCtx: Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
|
|
oCtx.Add "__ProviderArchitecture", ProviderArchitecture
|
|
oCtx.Add "__RequiredArchitecture", True
|
|
Dim oLocator: Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
|
|
oLocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
|
|
oLocator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
|
|
Dim oReg: Set oReg = oLocator.ConnectServer(Resource, "root\default", "", "", , , , oCtx).Get("StdRegProv")
|
|
Dim oInParams: Set oInParams = oReg.Methods_("EnumKey").InParameters
|
|
oInParams.hDefKey = hDefKey
|
|
oInParams.sSubKeyName = sSubKeyName
|
|
Dim oOutParams: Set oOutParams = oReg.ExecMethod_("EnumKey", oInParams, , oCtx)
|
|
If oOutParams.ReturnValue = 0 Then Set EnumValues = oOutParams
|
|
End Function
|
|
|
|
Function GetMultiStringValue (ByVal Resource, ByVal hDefKey, ByVal sSubKeyName, ByVal sValueName, ByVal ProviderArchitecture)
|
|
Const wbemAuthenticationLevelPktPrivacy = 6
|
|
Const wbemImpersonationLevelImpersonate = 3
|
|
Dim oCtx: Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
|
|
oCtx.Add "__ProviderArchitecture", ProviderArchitecture
|
|
oCtx.Add "__RequiredArchitecture", True
|
|
Dim oLocator: Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
|
|
oLocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
|
|
oLocator.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
|
|
Dim oReg: Set oReg = oLocator.ConnectServer(Resource, "root\default", "", "", , , , oCtx).Get("StdRegProv")
|
|
Dim oInParams: Set oInParams = oReg.Methods_("GetMultiStringValue").InParameters
|
|
oInParams.hDefKey = hDefKey
|
|
oInParams.sSubKeyName = sSubKeyName
|
|
oInParams.sValueName = sValueName
|
|
Dim oOutParams: Set oOutParams = oReg.ExecMethod_("GetMultiStringValue", oInParams, , oCtx)
|
|
If oOutParams.ReturnValue = 0 Then GetMultiStringValue = oOutParams.sValue
|
|
End Function |