Answers for "c# read registry data"

C#
5

c# read registry data

//Writing
//accessing the CurrentUser root element  
//and adding "OurSettings" subkey to the "SOFTWARE" subkey  
RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\OurSettings"); 

//storing the values  
key.SetValue("Setting1", "This is our setting 1");  
key.SetValue("Setting2", "This is our setting 2");  
key.Close(); 

//Reading
//opening the subkey  
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\OurSettings");  
              
//if it does exist, retrieve the stored values  
if (key != null)  
{  
    Console.WriteLine(key.GetValue("Setting1"));  
    Console.WriteLine(key.GetValue("Setting2"));  
    key.Close();  
}
Posted by: Guest on October-01-2020

C# Answers by Framework

Browse Popular Code Answers by Language