More Registry Stuff

In addition to GetSetting and SaveSetting, VBA provides the GetAllSettings statement. This statement is used to get all of the settings for a particular section in the registry at one time. It returns a two dimensional array: the first dimension is the key and the second dimension is the key’s value. For instance:

Sub UseGetAllSettings()

    Const sAPPNAME As String = “Euchre”
    Const sSECTION As String = “PlayerData”
    Dim vaSettings As Variant
    Dim i As Long
    SaveSetting sAPPNAME, sSECTION, “Name”, “Paul”
    SaveSetting sAPPNAME, sSECTION, “Age”, 35
    vaSettings = GetAllSettings(sAPPNAME, sSECTION)
    For i = LBound(vaSettings) To UBound(vaSettings)
        Debug.Print vaSettings(i, 0) & “:” & vbTab & vaSettings(i, 1)
    Next i
End Sub


Posted in Uncategorized

2 thoughts on “More Registry Stuff

  1. Nice to see the reference to euchre. Michigan transplants living in California rarely get much euchre exposure!

  2. When I first got into VBA, I read about writing to the reg., I tried it out, but I have never really need to use it. Can anyone suggest a situation where you would and the advantages over other methods?

    There is a saying in the Linux community, “He who messes with root, kills trees”. I personally like to stay a way from the notoriously f##ked up windows registry, but in modern day computing you can’t really help it. Spy wear etc, just loves digging in here, you end up deleting stuff you know nothing about and be for you know where you are, you systems beggared! Last night i spent 3 hours fix a mate PC, ‘cus he ran MSCONFIG, and balls it up! I’m not telling him about REGEDIT!!!!!

Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published.