This is not working for me:
public bool createRegistry()
{
if (!registryExists())
{
Microsoft.Win32.Registry.LocalMachine.CreateSubKey("Software\\xelo\\");
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\xelo").SetValue("hostname", (string)hostname, Microsoft.Win32.RegistryValueKind.String);
return true;
}
else
{
return updateRegistry();
}
}
The exception error is to do with Not Authorized to do this. Any Help would be apreaciated
Exeption: System.UnauthorizedAccessException | "Cannot write to the registry key"
For the working answer read the comment on the accepted Solution