Highlighted
Absent Member.
Absent Member.
243 views

[archive] Renaming a key in Windows Registry

[Migrated content. Thread originally posted on 10 June 2008]

I am trying to rename a subkey in the windows registry and it appears as though there is not a way to do this with a simple command. From a lot of the searching I've done, it seems like I must create new entries for each of the values underneath my subkey and then delete the original. Is this true? Does anyone have a sample program in COBOL that does this?

For example, I want to rename the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Robstan

to:

HKEY_LOCAL-MACHINE\SOFTWARE\NewRobstan

There are several subkeys and values underneath Robstan. I'd love to hear some suggestions on this one. Thanks in advance!

Rob
0 Likes
1 Reply
Highlighted
Absent Member.
Absent Member.

RE: [archive] Renaming a key in Windows Registry

There is no "rename" functionality in the Windows API on the registry, so your best bet is to delete the key and create it over again. This is actually deliberate from Microsoft. The more modifications that are done to the keys, the more fragmented the registry will become and thus impact performance.
The API does however have a somewhat related mechanism, RegReplaceKey, this will allow you to replace a key and its hive in that it will create a new registry which will be loaded next time the OS is started (This is one of the reasons installing new software will tell you to reboot...). This function is however not available from the ACUCOBOL-GT library functions.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.