hexagon logo

Registry Pearls

I recently drew a blank when trying to read/write the values (matrix) in "USE_PART_SETUP". I also came up empty trying to obtain the "default rotation angle about connection" for a probe build. Looking over all the available properties left me with nothing and I wondered if it might be in the registry (I wasn't able to find them there either). I did end up with the following routine which dumps all registry settings to an Excel worksheet (in my case over 4,000). Although I wouldn't recommend changing anything it shouldn't hurt to look. Comparing a before/after snapshot has helped determine what values are affected by running a code snippet. This is run from Excel VBA, uses a blank worksheet named "Scratch", and needs a reference to "Microsoft Scripting Runtime" for the dictionary object.
Sub ListPcDmisRegistrySettings()
    ' need PcDmis running (part program not required)
    
    Dim oApp As PCDLRN.Application
    Dim oRegSettings As PCDLRN.RegistrySettings
    Dim oRegSetting As PCDLRN.RegistrySetting
    Dim i As Integer
    
    Dim dicAccLvl As Scripting.Dictionary
    Dim dicGrp As Scripting.Dictionary
    Dim dicVarType As Scripting.Dictionary
    
    Set dicAccLvl = New Scripting.Dictionary
    Set dicGrp = New Scripting.Dictionary
    Set dicVarType = New Scripting.Dictionary
    
    With dicAccLvl
        .Add 0, "Admin"
        .Add 1, "User"
    End With
    With dicGrp
        .Add 1, "Machine"
        .Add 0, "User"
    End With
    With dicVarType
        .Add 5, "Whole Number"
        .Add 13, "Real Number"
        .Add 15, "True/False"
        .Add 19, "String"
    End With
    
    Set oApp = CreateObject("PCDLRN.Application")
    Set oRegSettings = oApp.GetRegistrySettings
    
    On Error Goto Cleanup
    oApp.Visible = False  'for PcDmis
    Application.ScreenUpdating = False  'for Excel
    
    ActiveWorkbook.Sheets("Scratch").Activate
    Sheets("Scratch").Rows("1:" & Rows.Count).ClearContents
    
    Cells(1, 1) = "AccessLevel" ' 0=Administrator or 1=User (RS_ACCESS Enum)
    Cells(1, 2) = "Group"       ' 1=Machine or 0=User (RS_GROUP Enum)
    Cells(1, 3) = "KeyName"     ' Section Name
    Cells(1, 4) = "Type"        ' 5=Whole Number,   13=Real Number,   15=True/False,   19=String
    Cells(1, 5) = "Used"        ' Used by the application
    Cells(1, 6) = "ValueName"   ' Entry Name
    Cells(1, 7) = "Value"       ' Entry Value
    
    i = 2
    For Each oRegSetting In oRegSettings
        Cells(i, 1) = dicAccLvl.Item(oRegSetting.AccessLevel)
        Cells(i, 2) = dicGrp.Item(oRegSetting.Group)
        Cells(i, 3) = oRegSetting.KeyName
        Cells(i, 4) = dicVarType.Item(oRegSetting.Type)
        Cells(i, 5) = oRegSetting.Used
        Cells(i, 6) = oRegSetting.ValueName
        Cells(i, 7) = oRegSetting.Value
        i = i + 1
    Next oRegSetting
    'Worksheets("Scratch").Columns("A:G").AutoFit
 
Cleanup:   
    oApp.Visible = True
    Application.ScreenUpdating = True
    
    Set dicAccLvl = Nothing
    Set dicGrp = Nothing
    Set dicVarType = Nothing
    Set oRegSetting = Nothing
    Set oRegSettings = Nothing
    Set oApp = Nothing
End Sub