Code: Select all
Option Explicit
'
'Registry reading code based on examples here: www.vbforums.com/showthread.php?t=567903
'
Dim oReg As Object, Results() As String
Private Const HKEY_CURRENT_USER As Long = &H80000001
Private Const REG_BINARY = 3
Private Type RegData
strKeyName As String
strValueName As String
strData As String
End Type
Dim Regd() As RegData
Code: Select all
Dim strPath As String, arrValues As Variant, strValue As Variant, arrTypes As Variant
Dim i As Integer, j As Integer, Cnt As Integer, EJ As String, EJ_Flag As Integer
'
ReDim Regd(0)
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
strPath = "Software\Microsoft\Office\" & Application.Version & "\Excel\Resiliency\DisabledItems\"
'
oReg.enumvalues HKEY_CURRENT_USER, strPath, arrValues, arrTypes
'
If Not IsNull(arrValues) Then
ReDim Preserve Regd(UBound(Regd) + UBound(arrValues) + 2)
For i = 0 To UBound(arrValues)
EJ = ""
EJ_Flag = 0 'we look for ":\" (and there is a chr(0) in between)
strValue = vbNullString
Select Case arrTypes(i)
Case REG_BINARY
oReg.getbinaryvalue HKEY_CURRENT_USER, strPath, arrValues(i), strValue
For j = 0 To UBound(strValue)
Select Case EJ_Flag
Case 0
EJ_Flag = IIf(strValue(j) = 58, 1, 0)
Case 1
EJ_Flag = IIf(strValue(j) = 0, 2, 0)
Case 2
EJ_Flag = IIf(strValue(j) = 92, 3, 0)
Case 3
If strValue(j) <> 0 Then EJ = EJ + Chr(strValue(j)) 'Build the string
End Select
Next
End Select
'
Cnt = Cnt + 1
ReDim Preserve Results(2, Cnt)
Results(1, Cnt) = arrValues(i)
Results(2, Cnt) = Extract(EJ)
Next
End If
Set oReg = Nothing
(The "extract" routine simply pulls the addin name from the string)
Code: Select all
Function Extract(Source As String) As String
Dim i As String, j As Integer
i = InStr(Source, ".xla")
j = InStrRev(Source, "\")
Extract = Mid(Source, j + 1, i - j - 1)
End Function