Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need Simplified Registry Solution Code Snipits

Posted on 1998-10-29
5
Medium Priority
?
172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 300 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

704 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