Solved

Need Simplified Registry Solution Code Snipits

Posted on 1998-10-29
5
165 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Excel object stays open 19 65
VB error "Type mismatch" 2 42
Paint/Redraw window while dragging 16 56
Run code from text file in vb 1 32
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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

743 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

16 Experts available now in Live!

Get 1:1 Help Now