private void button1_Click(object sender, EventArgs e)
{
try
RegistryKey regkey = Registry.CurrentUser;
regkey = regkey.CreateSubKey (@"Software\Tanmay\Sample"); //path
if (regkey != null)
regkey.SetValue("Test", "Hello World"); //Value Name,Value Data
}
catch (Exception ex)
MessageBox.Show(ex.Message);
Mark it as answer if it help you.
Thank you.