Change registry key's name

D

Dmitriy Kolesnik

Hello, all!

I have next problem: I don't know how I can change registry key's name in
C#. Help me please, if you know solution of this problem.

Thank You.
 
O

Oliver Sturm

Dmitriy said:
I have next problem: I don't know how I can change registry key's name in
C#. Help me please, if you know solution of this problem.

Registry keys cannot be renamed. The managed registry wrapper also
doesn't have the ability to copy a key, as far as I know. You'll have to
use the API function RegCopyTree to make a copy of the key in question,
complete with children, then delete the original key.


Oliver Sturm
 
O

Oliver Sturm

Oliver said:
You'll have to
use the API function RegCopyTree to make a copy of the key in question,
complete with children, then delete the original key.

I just found that this API function is apparently very new, docs at MS
say it's only available in Longhorn. I didn't notice that before because
I didn't assume there would be registry API functions that are actually
only introduced in Longhorn.

So, the alternative approch should be to create a new key, iterate
recursively through the source key and its children and copy them over
to the new key. Finally, delete the old key. The advantage is that you
should be able to do that with the normal managed registry wrappers that
the .NET SDK provides.



Oliver Sturm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top