In my .msi installer package, I have a C# custom action that writes a registry value in:
HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion
Microsoft.Win32.RegistryKey key;
key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Names");
key.SetValue("Name", "Isabella");
key.Close();
Do you try this, here reference from microsoft
Edit:
string strSID = "";
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
NTAccount ntuser = new NTAccount(userName);
SecurityIdentifier sID = (SecurityIdentifier)ntuser.Translate(typeof(SecurityIdentifier));
strSID = sID.ToString();
Registry.Users.SetValue(sID + @"\key", value);
Try this, you should probably read about Registry.Users.SetValue
You need:
using System.Security.Principal;
for this code.