Reputation: 5203
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?
Upvotes: 2
Views: 3178
Reputation: 86688
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 use RegSaveKey
or similar.
If you don't want to use the APIs, you can use reg.exe
. Let's say you have a key called HKLM\Software\Comm
but you want it to be HKLM\Comm
. You would execute something like:
reg save HKLM\Software\Comm comm.hiv reg load HKLM\Comm comm.hiv
Upvotes: 4