Solved

Need Simplified Registry Solution Code Snipits

Posted on 1998-10-29
5
168 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

829 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