The following code is not working for me:
public bool createRegistry()
{
if (!registryExists())
{
Microsoft.Win32.Registry.LocalMachine.Creat
Below code to create key in the registry.
Microsoft.Win32.RegistryKey key;
key = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("Software\\Wow6432Node\\Names");
key.SetValue("Name", "Isabella");
key.Close();
Set the Premission Check bit to true...
Microsoft.Win32.Registry.LocalMachine.CreateSubKey("Software\\xelo\\", true);
:)
Even when admin I don't think you can create new keys off LocalMachine. Make sure that you do
Registry.LocalMachine.CreateSubKey(@"SOFTWARE\YourCompanyName\SomeNewKey");
and not
Registry.LocalMachine.CreateSubKey("SomeNewKey");
Well you've got your answer already - I'm guessing you're running on Vista or Windows 7 (or Server 2008) and the process/user running the app doesn't have rights/permission to modify the registry.
So its not a code problem as such but a systems admin one. Build the app and run as administrator and see if that works.
Non-admin and unelevated admin users don't have rights to modify the HKEY_LOCAL_MACHINE key. Run the program 'as administrator'.