Solved

Need Simplified Registry Solution Code Snipits

Posted on 1998-10-29
5
166 Views
Last Modified: 2012-05-04
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.
0
Comment
Question by:rayford
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:fguerreiro_inix
ID: 1442388
Use GetSettings and SaveSettings and DeleteSettings functions, they come with VB and are very easy to use.

Hope this helps
Regards
0
 
LVL 1

Author Comment

by:rayford
ID: 1442389
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!  
0
 
LVL 2

Expert Comment

by:Poddy
ID: 1442390
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
0
 
LVL 3

Accepted Solution

by:
fguerreiro_inix earned 150 total points
ID: 1442391
The following example first uses the SaveSetting statement to make entries in the Windows registry (or .ini file on 16-bit Windows platforms) for the MyApp application, and then uses the DeleteSetting statement to remove them.

' Place some settings in the registry.
SaveSetting appname := "MyApp", section := "Startup", _
            key := "Top", setting := 75
SaveSetting "MyApp","Startup", "Left", 50
' Remove section and all its settings from registry.
DeleteSetting "MyApp", "Startup"

To get the settings see this:
Debug.Print GetSetting(appname := "MyApp", section :=  _               "Startup", key := "Left", default := "25")

Enjoy it
Hope this helps



0
 
LVL 1

Author Comment

by:rayford
ID: 1442392
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!

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now