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

Post New Resource Bookmark and Share   

C# Registry Operations

Posted By:Ghanashyam Nayak       Posted Date: June 04, 2011    Points: 200    Category:    URL: http://www.dotnetspark.com  

This article describes performing different-different operations on the registry.

This article describes performing different-different operations on the Windows registry.
//Create a Particular Registry.
private void btnCreateRegistry_Click(object sender, EventArgs e)
     RegistryKey RegCreateKey = default(RegistryKey);     
     RegCreateKey = My.Computer.Registry.CurrentUser.CreateSubKey("ApplicationName\\CompanyName");
//Delete a Partucular Registry.
private void btnDeleteRegistry_Click(object sender, EventArgs e)
     using (RegistryKey RegDeleteKey = My.Computer.Registry.LocalMachine.OpenSubKey("SoftwareName"))     
//Read a Particular Registry.
private void btnReadRegistry_Click(object sender, EventArgs e)
     object RegReadKeyValue = null;
     RegReadKeyValue = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\\SoftwareName\\CompanyName\\KeyName", "ValueName", "DefaultValue");

//Write a Particular Registry.
private void btnWriteRegistry_Click(object sender, EventArgs e)
     My.Computer.Registry.SetValue("HKEY_CURRENT_USER\\Software\\CompanyName\\KeyName", "Name", "Value");

//Check the registry is exist or not?
private void btnCheckRegistry_Click(object sender, EventArgs e)
     bool IsRegExists = false;     
          //Here it will check the particular given registry.      
          if (My.Computer.Registry.CurrentUser.OpenSubKey("Software\\Company\\Application\\1.1") != null)          
               //Given registry key is exist...               
               IsRegExists = true;          


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply

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