Results 1 to 20 of 20

Thread: Working with Windows Registry using Visual Basic 6 - A complete Tutorial

Threaded View

  1. #3

    Thread Starter
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Writing to The Windows Registry

    To write to the registry we will use the SaveSetting command. SaveSetting Saves or creates an application entry in the application's entry in the Windows Registry. Visual Basic, by default using GetSetting and SaveSetting allows reading and writing only to the VB and VBA Programs key under HKEY_Current_User\Software.

    Syntax

    SaveSetting appname, section, key, setting

    The SaveSetting statement syntax has these named arguments:

    Part Description
    appname Required String expression containing the name of the application orproject to which the setting applies.
    section Required String expression containing the name of the section where the key setting is being saved.
    key Required String expression containing the name of the key setting being saved.
    setting Required Expression containing the value that key is being set to.

    Lets understand the syntax...
    You can compare the registry to a database which has fields and records in it...
    The first three arguments of the SaveSetting statement can be compared to fields in a record. The field names just happen to be appname, section, key and setting and we need to simply supply values to this via SaveSetting.

    The best thing about the SaveSetting statement is that you can specify any values you want for appname, section and key. However please ensure that you pick something meaningful. The last field "setting" holds the value that we are really interested in. Lets try it with an example which uses the SaveSetting statement to make entries in the Windows registry for the MyApp application.

    vb Code:
    1. '~~> Place some settings in the registry.
    2. SaveSetting appname := "MyApp", section := "Startup", key := "Top", setting := 75
    3. 'Or
    4. SaveSetting "MyApp","Startup", "Top", 75

    What this code does is that it saves the .Top value of your startup form in the Windows Registry.

    Once this line of code executes, a 'record' is written to the Windows Registry with these four 'field' values. If you want to check this out for yourself, you can start the Registry Editor again, and search for the value by selecting Edit-Find from the Registry Editor's Menu Bar.



    Last edited by Siddharth Rout; Mar 26th, 2009 at 05:11 AM.
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

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