.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Code Snippets >> System Registery >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Write to System Registry

Posted By:Pankaj Mishra       Posted Date: August 11, 2008    Points: 10    Category: System Registery    URL: http://www.dotnetspark.com  

Using below function you can write to system registry using C# or Vb.Net

Sometimes we need to write to system registry. For ex you can save connectionstring to systen Registry, Software trial information etc. this also helpful when you want to hide information from normal user then its recommended to save information into system registery.

so below is the solution to write into system registery.

in C# example

public static void WriteToRegistry(string keyToWrite,object valueToWrite,string path)

       RegistryKey oRegistry = Registry.LocalMachine.CreateSubKey(path);

     if(oRegistry != null)




In Vb.Net sample method

Public Shared Sub WriteToRegistry(ByVal keyToWrite As String, ByVal valueToWrite As Object, ByVal path As String)
    Dim oRegistry As RegistryKey = Registry.LocalMachine.CreateSubKey(path)
    If oRegistry IsNot Nothing Then
        oRegistry.SetValue(keyToWrite, valueToWrite)
    End If
End Sub
Above method is accepting the key and value as an input




Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend