Results 1 to 4 of 4

Thread: Using ini or registry

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    3

    Talking Using ini or registry

    Hello,

    I need to make use of the registry or ini files in order to store basic user data.
    I am using VB6, and I had problems fetching sample code about doing this.

    Any help will be greatly appreciated.


    Yours,

    Vlad.

  2. #2
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    Reading and writing data to and from the registry is easy.

    VB in fact uses HKEY_CURRENT_USER\SOFTWARE\VB AND VBA PROGRAM SETTINGS\app name
    to store and retrieve data using savesetting and getsetting

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4. 'create new registry settings
    5. SaveSetting "test reg app", "users\user1", "Name", "Paul"
    6. SaveSetting "test reg app", "users\user1", "Location", "Woolloomooloo"
    7. End Sub
    8.  
    9. Private Sub Command2_Click()
    10. 'get at the registry settings
    11. MsgBox GetSetting("test reg app", "users\user1", "name")
    12. MsgBox GetSetting("test reg app", "users\user1", "location")
    13. End Sub
    14.  
    15. Private Sub Command3_Click()
    16. 'Delete the registry settings
    17.  
    18. 'DeleteSetting "test reg app", "users\user1", "name" 'delete a key
    19. DeleteSetting "test reg app", "users" 'delete beneath test reg app\users
    20. 'DeleteSetting "test reg app" 'delete all beneath test reg app
    21. End Sub
    22.  
    23. This site has a few good tutorial on the registry too:
    24. [url]http://www.vb-world.com/registry/[/url]

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Using registry:
    VB Code:
    1. dim opt_Username as string
    2.  
    3. opt_Username="Eddie"
    4. SaveSetting  "MyApp", "UserInfo", "Username", opt_Username
    5. opt_UserName=GetSetting("MyApp","UserInfo","Username","JohnDoe")
    6. msgbox "Now check your registry!"

  4. #4
    Hyperactive Member scsa20's Avatar
    Join Date
    Apr 2001
    Location
    Mars
    Posts
    456
    I prever registry cuz no one bother missing with the registry...anyways, I added a molude that let's you use the registry...to add something to the registry, use the following code:

    VB Code:
    1. Private Sub Command1_Click()
    2. SaveSettingString HKEY_CURRENT_USER, "Software\App", "String Title", "String information"
    3. End Sub


    p|-|34|2 /\/\3 f0|2 | $p34k 1337
    My TSS quote of the day: "If your haveing a bad day, just press the restart button."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width