Results 1 to 5 of 5

Thread: [Help]Need help with Registry

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Posts
    76

    Angry [Help]Need help with Registry

    Hi guys,

    I am creating a project which needs to update/create/modify etc the registry. I am able to all the things, the problem in which i am stuck is that after editing Registry changed doesnot take place instantly i have to log off/log in to se changes to take place.

    I am looking for a way to update the registry without logging off and on. Can any one help me.
    Last edited by riteshtechie; Nov 23rd, 2009 at 05:49 AM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [Help]Need help with Registry

    I think you'll find that any changes you make to the Registry are immediate. Perhaps you're changing some seeting that are only read from the Registry by the OS at startup. For those to actually take effect you would have to log off and back on again, but the Registry should still contain the new information without that. If this doesn't seem to be the case, can you provide an example?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Hyperactive Member gonzalioz's Avatar
    Join Date
    Sep 2009
    Location
    <body></body>
    Posts
    508

    Re: [Help]Need help with Registry

    I edit registry values as well, but they change instantly. Maybe I am using different methods? These are a few methods that I use:

    OpenSubKey
    vb Code:
    1. Dim key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\" & My.Application.Info.AssemblyName)
    2.         With key
    3.             .SetValue("Value", value, Microsoft.Win32.RegistryValueKind.Binary)
    4.             .Close()
    5.         End With
    6.  
    7. or
    8.  
    9.         If key IsNot Nothing Then
    10.             With key
    11.                 GUID = .GetValue("GUID")
    12.                 .Close
    13.             End With
    14.         End If

    Note that I also call .Close on the registrykey. This maybe the reason that the key won't get updated instantly in your case.

    SetValue
    vb Code:
    1. Microsoft.Win32.Registry.SetValue("HKEY_CURRENT_USER\Software\" & My.Application.Info.AssemblyName, "Value", value)

    GetValue
    vb Code:
    1. Microsoft.Win32.Registry.GetValue("HKEY_CURRENT_USER\Software\" & My.Application.Info.AssemblyName, "Value", value)

    [EDIT]
    More information on .Close : http://msdn.microsoft.com/en-us/libr...key.close.aspx

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Posts
    76

    Re: [Help]Need help with Registry

    Code:
       
    Dim regKey As RegistryKey
    
    
     Private Sub adv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles adv.Click
            regKey = Registry.CurrentUser.OpenSubKey("Software\Policies\Microsoft\Internet Explorer\Control Panel", True)
    
            If adv.Text = "Hide" Then
                regKey.SetValue("AdvancedTab", 1)
                adv.Text = "Show"
                regKey.Close()
            Else
                regKey.SetValue("AdvancedTab", 0)
                adv.Text = "Hide"
                regKey.Close()
            End If
        End Sub
    Even after removing regKey.close() registry doesn't update
    Last edited by riteshtechie; Nov 23rd, 2009 at 05:49 AM.
    < advertising link removed by moderator >

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Posts
    76

    Re: [Help]Need help with Registry

    BUMP!!!!! Sorry I didn't find anything that could help me
    < advertising link removed by moderator >

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