CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2007
    Posts
    143

    Wink registry read and write

    Hi guys,

    is their any api present to read and write to registry in VB, kindly provide me some sample

  2. #2
    Join Date
    Sep 2008
    Posts
    16

    Re: registry read and write

    Quote Originally Posted by resumurof
    Hi guys,

    is their any api present to read and write to registry in VB, kindly provide me some sample
    VB6 makes this simple to do, just use
    SaveSetting
    and
    GetSetting
    Note: All values are stored as strings

    Example:
    If you wanted to save a window's current width on unload so it could be used the next time the window was opened, you could save it's current width to the registry using the below code.
    Code:
    Dim sWidth as String
    sWidth = CStr(oForm.width)
    SaveSetting "MyAppName", "MyWindow", "Width", sWidth
    Where oForm is the form being closed


    Then to retrieve the value:
    Code:
    Dim sDefaultValue as String
    'sDefaultValue is used if registry value is not found
    sDefaultValue = "600"
    iWindowWidth = CInt(GetSetting("MyAppName", "MyWindow", "Width", sDefaultValue)
    oForm.Width = iWindowWidth

  3. #3
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: registry read and write

    Keep in mind that the getsetting and save setting functions write to the current user section of the registry under software.


    This is the easiest way to write to the registry but there is also API calls that can be used which will allow you to write to other areas in the registry when needed.

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

Featured