C# Create Values in Registry Local Machine

Posted by Shahmir Javaid on Stack Overflow See other posts from Stack Overflow or by Shahmir Javaid
Published on 2010-04-27T17:18:47Z Indexed on 2010/04/27 17:23 UTC
Read the original article Hit count: 302

Filed under:
|

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"

© Stack Overflow or respective owner

Related posts about c#

Related posts about registry