Home > DeveloperSection > Forums > How to create a new subkeys under registry
Anupam Mishra

Total Post:135

Posted on    January-20-2016 5:59 AM

 C# C#  .NET 

 1 Reply(s)
 213  View(s)
Rate this:
I want to create a subkeys under the root key in my local machine. Please give me a appropriate example to create a new subkey.

thank you.

Anupam Mishra

Total Post:135

Posted on    January-21-2016 1:46 AM

In C#,  Register class is defined  under  Microsoft.Win32 namespace Register class is used to manipulate the system registry. It represents a Key level node in the windows registry.  The registry acts as information for the operating system and application on a computer. Register keys are the base unit of registry. Each key have multiple values alone with it.

For creation of new subkey under the registry, we are using CreateSubKey method to creates a new subkey or opens an existing subkey for write access.
    RegistryKey key;
          key = Registry.CurrentUser.CreateSubKey("Anupam Software"); // you can change root directory e.g. LocalMachine
          key.SetValue("Anupam", "My Software");

 It will create a subkey under the current User(HKEY_USERS) like below screen :

Modified On Jan-21-2016 01:49:03 AM

Don't want to miss updates? Please click the below button!

Follow MindStick