Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

does Registry.CurrentUser.OpenSubKey create the key if it does not exist?

// No it does not - create it manually on null check
public void ConfigureWindowsRegistry()
{
    RegistryKey localMachine = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64); //here you specify where exactly you want your entry

   var reg = localMachine.OpenSubKey("SoftwareMicrosoftOfficeOutlookFormRegions	esssst",true);
   if (reg == null)
   {
       reg = localMachine.CreateSubKey("SoftwareMicrosoftOfficeOutlookFormRegions	esssst");
   }

   if (reg.GetValue("someKey") == null)
   {
       reg.SetValue("someKey", "someValue");
   }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #create #key
ADD COMMENT
Topic
Name
7+2 =