-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadMultiStringValue.vbs
More file actions
37 lines (37 loc) · 1.6 KB
/
ReadMultiStringValue.vbs
File metadata and controls
37 lines (37 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'---------------------------------------------------------------------
'Name: ReadMultiStringValue(RegHive,RegKey,RegValue)
'Programmer: Hitesh Patel
'Purpose: Read the REG_MULTI_SZ value from given registry.
'Example: ReadMultiStringValue("HKEY_LOCAL_MACHINE","SYSTEM\CurrentControdlSet\Control\Session Manager","PendingFileRenameOperations")
'Notes: This Function returns an ARRAY of values if read is successful OR returns ZERO (Boolean value) if key is not present or read is unsuccessful.
'Return Code Processing : Catch the functions return code using IsArray() method
'-------------------------------------------------------------------
Function ReadMultiStringValue(RegHive,RegKey,RegValue)
Select Case RegHive
Case "HKEY_CLASSES_ROOT"
Const HKEY_CLASSES_ROOT = &H80000000
Case "HKEY_CURRENT_USER"
Const HKEY_CURRENT_USER = &H80000001
Case "HKEY_LOCAL_MACHINE"
Const HKEY_LOCAL_MACHINE= &H80000002
Case "HKEY_USERS"
Const HKEY_USERS = &H80000003
Case Else
End Select
'....................................
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_
strComputer & "\root\default:StdRegProv")
strKeyPath = RegKey
strValueName = RegValue
Return = objReg.GetMultiStringValue(HKEY_LOCAL_MACHINE,strKeyPath,_
strValueName,arrValues)
MsgBox "call to reg " & Return
'-----------------------
If (Return = 0) And (Err.Number = 0) Then
ReadMultiStringValue = arrValues
Else
ReadMultiStringValue = 0
End If
END Function
'---------------------------------------------------------------------