Updating Data field of Value in Registry

G

Guest

Here is what I want to do:

Presently in my registry I have:

(Default) = "C:\Program Files\myApp" and this value is scattered all over
registry in several keys and subkeys.

I wouldlike to have write a small c# app that will search the Data file
"C:\Program Files\myApp" and replace it with "E:\Data\myApp". In regedit one
can search for a certain data, but you can't do "Replace All" with a certain
data type, hence this quest for writing and learning to interact with
Registry.

I have written apps in the past to read specific registry values, but
nothing generic of this nature. Can someone point me and advise me on how to
do this. Any and all help is greatly appreciated.

Regards, LCD
 
N

Nicholas Paldino [.NET/C# MVP]

LCD,

This is a function you will have to perform manually. Unless you are
writing a general-purpose app to do this, I wouldn't recommend doing this.
It is possible that there are other registry keys in your system that have
this value in it which should not be replaced.

If you wanted to do this, you would basically have to iterate through
all of the keys recursively (your implementation shouldn't be recursive, but
the operation is a recursive one, to say the least). You would open the
registry key for the root nodes (maybe not all of them, because some of them
are really references to nodes in other trees), and check to replace your
value (through a call to GetValueNames and GetValue).

Then, you would call GetSubKeyNames to get the names of all the sub keys
of the current registry key, and perform the same operation on them.

Hope this helps.
 
D

D. Yates

On Nov 10th Willy Denoyette [MVP] referred to a Microsoft Tool called
LogParser in a posting labeled "Search for a registry key with a certain
value" which may help you.

Google for it....


Dave
 

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