I need to add a key under HKLM for testing my application? But windows does not allow me to create a key under HKLM. I am getting the error message "Cannot create key: Error writing to the registry." when I try to create a key under HKLM.
How can I create a key under HKLM?
You cannot actually create a direct child of HKU or HKLM. In order to create a subkey of HKLM (as it appears you’re trying to do), you have load a registry hive file with an API like
RegLoadKey. So where do you get a hive file to load? I believe you need to useRegSaveKeyor similar.If you don’t want to use the APIs, you can use
reg.exe. Let’s say you have a key calledHKLM\Software\Commbut you want it to beHKLM\Comm. You would execute something like: