Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 674
  • Last Modified:

How do I rename a registry key using MFC

I need to rename a particular registry key. Is there a single API function to do this? or Should I create my new registry key and copy the previous one into this and finally delete the original.
0
AmitAgarwal
Asked:
AmitAgarwal
1 Solution
 
PacmanCommented:
Yes you have to copy and delete it.
0
 
BogdyPtrCommented:
Yup, you have to copy the key.
You can use RegLoadKey and RegSaveKey to make the copy via a temp file.
You can use CRegKey::RecurseDeleteKey to delete all the subkeys more easy.
0
 
peterchen092700Commented:
just to add some "manpower" to the statement: Copy&Delete is the only way, and even RegEdit implements it this way.

Peter
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
jhanceCommented:
For 25 points you get the answer and you can code or locate an implementation yourself.

For 150-200 points, I'm sure someone would be happy to supply the source code to make this happen for you.
0
 
AmitAgarwalAuthor Commented:
Thanx a lot.
jhance there is no problem in implementing the code i was just wondering how this is not supplied as a single API.
i am giving point to Pacman because he was the first person to answer this. Thanks to everybody

love
amit
0
 
sysaddixCommented:
According to MSDN:

RegSaveKey is often used in conjunction with RegRestoreKey to copy subtrees in the registry. An alternative to this approach is to use the SHCopyKey function.

I am currently trying to see if this will copy a key - then its just a two step approach.

mjdalways
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now