I am trying to create a registry key at following location but I am getting access denied error:
HKEY_LOCAL_MACHINE\\SOFTWARE\\MyCompany\\MyProgram
You need to run your application under an account that has sufficient privileges to write to the registry at the specified location. Usually the HKEY_LOCAL_MACHINE branch is reserved for power users because it contains machine global settings.
HKEY_LOCAL_MACHINE