Hi Rick,
I found the solution
the opensubkey is an overloaded method. IF you want to write to it then you should pass a boolean flag as below
RegistryKey HkSoftware = Hklm.OpenSubKey("Software",true);
Thanks
>Are you logged in as an Administrator group account? Without that you can't write to Local Machine only to the user keys.
>
>+++ Rick ---
>
>>Hi guys,
>>i am trying to create a registry key in my code but i keep getting system.unauthorizedaccessexception occured in mscorlib.dll , cannot write to registry key.
>>
>>here is my code
>>
>>using Microsoft.Win32;
>>
>>RegistryKey Hklm = Registry.LocalMachine;
>>RegistryKey HkSoftware = Hklm.OpenSubKey("Software");
>>// errror on the line below
>>RegsitryKey Hkmycompany = Hkml.CreateSubKey("mycompany");
>>
>>Can anyone help me.
>>
>>TIA
Fred Besterwitch, MCP
The harder you work. The luckier you get.