Link to home
Start Free TrialLog in
Avatar of rayford
rayford

asked on

Need Simplified Registry Solution Code Snipits

Ok I've decided to take the plunge and stop using INI files but I need something easier to work with than the existing Registry API calls.  Surely someone else has devised a few simple routines to ExistsRegEntry, LoadRegEntry, AddRegEntry and UpdateRegEntry?  Please provide Functions.
Avatar of fguerreiro_inix
fguerreiro_inix

Use GetSettings and SaveSettings and DeleteSettings functions, they come with VB and are very easy to use.

Hope this helps
Regards
Avatar of rayford

ASKER

If you apparently know exactly where these routines are located, then please cut and paste them to provide the code (as requested) so I can award you the points.  Thanks!  
They are part of vb... press f1 for help

However, they restrict access to a certain sub tree of the registy.... Try looking at another Q - i'm sure this Q has been asked before in the last few days
ASKER CERTIFIED SOLUTION
Avatar of fguerreiro_inix
fguerreiro_inix

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rayford

ASKER

Yes they are.  Thank you.  Here is an example of something more like what I was hoping for actually.  The following is some practical simple code to demonstrate the use of these functions and avoid too much experimentation with the registry:

Public Sub SaveList(ctrList As Control)

  Dim intIndex As Integer
  ' Remove old list
  On Error Resume Next
  DeleteSetting App.EXEName, "List_" & ctrList.Name
  On Error GoTo 0
 
  ' Save list items
  For intIndex = 0 To ctrList.ListCount - 1
    SaveSetting App.EXEName, "List_" & ctrList.Name, _
      "Item_" & Format(intIndex, "000"), _
      ctrList.List(intIndex)
  Next intIndex
 
  ' Save item count
  SaveSetting App.EXEName, "List_" & ctrList.Name, _
    "Count", _
    Format(ctrList.ListCount)
 
End Sub

Public Sub GetList(ctrList As Control)

  Dim intIndex As Integer
  Dim intCount As Integer

  ' Clear the list
  ctrList.Clear
 
  ' Get list count
  intCount = CInt(GetSetting(App.EXEName, "List_" & ctrList.Name, _
      "Count", "0"))
 
  ' Add list items from registry
  For intIndex = 0 To intCount - 1
    ctrList.AddItem GetSetting(App.EXEName, "List_" & ctrList.Name, _
      "Item_" & Format(intIndex, "000"))
  Next intIndex
 
End Sub

Thanks!