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
  • RegMon from SysInternals is also a good app for monitoring registry access.

    When I think of it, all the apps from SysInternals are awesome for debugging/information fishing.
  • This is an interesting script - thank you! I would suggest an "ON ERROR GOTO CleanUp" directly after "oApp.Visible = False" and the label "CleanUp:" just before "oApp.Visible = True", as PC-DMIS will be left in the invisible state if something goes wrong between those lines.

    Do you know what the "Used by the application" signifies? That it has been changed from default in Settings Editor? Is there a way to find the default value too?


    And a +1 for the Sysinternals programs - they have helped me with many Windows problems.
  • I couldn't find any default values using either Settings Editor or RegEdit. The only place I've seen the default values mentioned is in PCDMISREGISTRY.chm.

    All I can think of would be to first backup current state in Settings Editor. Then run Settings Editor as Admin. After connecting there is an option to "Reset Product". I assume this would be to default values. You could then have a look and afterwards restore the backup. I'm guessing here!

    One nice thing about using Excel is the ability to easily sort by value making it easier to finds it's entry. If you do use Excel you may want to format the value column as text to display what was intended.
  • I performed the Backup-Reset Product-Restore sequence on my offline machine with questionable results. I looked at some values in Settings Editor before the restore and found entries in bold(meaning they had been modified from default). This box had v2013 installed a year ago, then v2014 and now v2014.1. I believe the settings migrate forward at each software upgrade. If so it's possible that the default settings for the most recent installation included alterations made earlier (guessing again). I suppose the only way to obtain true default values may be to do a fresh initial install (vmware?). Even so, different software modules and hardware might have an influence.

    AndersI-
    Scripting only for myself I usually treat error checking like flossing my teeth. I know it's good and I'd be better off with it but don't seem to get around to doing it as often as I should. Having to reboot is an inelegant reminder. Helper code like above never gets into a finished app but helps move me along. I was surprised at the number of "properties" not otherwise available.

    vpt.se-
    I looked on the Sysinternals site for Regmon but couldn't find it. A notice on Technet mentioned it being removed some years ago. Is there another registry tool you find useful?
  • Regmon (and Filemon) has been superseded by Process Monitor - https://technet.microsoft.com/en-us/sysinternals/bb896645 - which combines them (and more).