Find & Replace in RegEdit Registry 
Author Message
 Find & Replace in RegEdit Registry

Hi All,

I was wondering, how easy is it to do Find & Replace within the
windows registry with Visual Basic.

Bascially, there are several string values which need changing from
e.g AAA to BBB under the HKCU\Software\VB & VBA Settings in several
folders.

I know how to do getsettings and savesettings etc, but not to search
and then change.

Any ideas on how to this task with VB?

Thanks



Sat, 03 Mar 2012 20:24:57 GMT  
 Find & Replace in RegEdit Registry


Quote:
> Hi All,

> I was wondering, how easy is it to do Find & Replace within the
> windows registry with visual basic.

> Bascially, there are several string values which need changing from
> e.g AAA to BBB under the HKCU\Software\VB & VBA Settings in several
> folders.

> I know how to do getsettings and savesettings etc, but not to search
> and then change.

> Any ideas on how to this task with VB?

You have to be a little clearer on 'Why' you are searching, as in most cases
simply writing a new value to a particular location (identified by the keys)
'replaces' the existing value. If your intentions are to add new keys and
values, then a simple write will work as well. So it looks like all you have
to do is delete the AAA keys and write the BBB keys.

Note: if you have to do this across multiple boxes, then a simple .reg file
placed in an Admin script, or P&D package, etc. would do the trick.

-ralph



Sat, 03 Mar 2012 20:51:59 GMT  
 Find & Replace in RegEdit Registry
"How to add, modify, or delete registry subkeys and values by using a
registration entries (.reg) file"
http://support.microsoft.com/kb/310516


Sat, 03 Mar 2012 21:02:17 GMT  
 Find & Replace in RegEdit Registry
Terry Tibbs escribi:

Quote:
> Hi All,

> I was wondering, how easy is it to do Find & Replace within the
> windows registry with visual basic.

> Bascially, there are several string values which need changing from
> e.g AAA to BBB under the HKCU\Software\VB & VBA Settings in several
> folders.

> I know how to do getsettings and savesettings etc, but not to search
> and then change.

> Any ideas on how to this task with VB?

> Thanks

It looks like you don't know where the keys that you want to replace
are. It's dangerous.


Sat, 03 Mar 2012 21:30:17 GMT  
 Find & Replace in RegEdit Registry
If you are doing this because you are getting "Invalid procedure call or
argument (Error 5)", then one of the registry entries was added manually by
the user in a non-String type, such as DWORD. VB always writes String type,
and generates the above error if the value is not string type.


Sat, 03 Mar 2012 21:47:10 GMT  
 Find & Replace in RegEdit Registry
Terry Tibbs escribi:

Quote:
> Hi All,

> I was wondering, how easy is it to do Find & Replace within the
> windows registry with visual basic.

> Bascially, there are several string values which need changing from
> e.g AAA to BBB under the HKCU\Software\VB & VBA Settings in several
> folders.

> I know how to do getsettings and savesettings etc, but not to search
> and then change.

> Any ideas on how to this task with VB?

> Thanks

Use RegEnumKeyEx and RegEnumValue to enumerate registry keys and values.
Then use InStr to see if you find the string(s).

http://allapi.mentalis.org/apilist/RegEnumKeyEx.shtml

http://allapi.mentalis.org/apilist/RegEnumValue.shtml

A sample code:
http://allapi.mentalis.org/apilist/253F9FB262EAA45DC6210E4066F9DFC3.html

Then use the APIs for saving to the registry to change them.
RegSetValueEx, etc.

http://allapi.mentalis.org/apilist/RegSetValueEx.shtml

Sample:
http://allapi.mentalis.org/apilist/4E1AB36884B253CE24768DA1C4080A14.html



Sat, 03 Mar 2012 21:55:55 GMT  
 Find & Replace in RegEdit Registry
Terry Tibbs escribi:

Quote:
> I know how to do getsettings and savesettings etc, but not to search
> and then change.

You can enumerate the keys that a VB program saved getting all them with
the buit in VB function GetAllSettings


Sat, 03 Mar 2012 22:00:45 GMT  
 Find & Replace in RegEdit Registry

Quote:

> Sample:
> http://allapi.mentalis.org/apilist/4E1AB36884B253CE24768DA1C4080A14.html

Another option is using the easy to use CRegistry class from the following
VB5/6 library:

http://sourceforge.net/projects/codebox/

There is a light weight version(CRegKey) for those how don't need to
enumerate keys or write binary values.



Sat, 03 Mar 2012 22:20:41 GMT  
 Find & Replace in RegEdit Registry
   If you don't want to get into the Registry
API (which is fairly complex) then look
up the GetAllSettings function. GetSetting
retrieves 1 value. GetAllSettings retrieves
a 2-dimensional array of all settings in
a subkey. But you'll need to know the key
names, and I'm not sure if you can enumerate
the top level. It's designed to take parameters
like:
 GetAllSettings("AcmeEditor", "Settings")
or
 GetAllSettings("AcmeEditor", "Settings\Windows")
 GetAllSettings("AcmeEditor", "Settings\Reg")

(And of course this only works under
HKCU\Software\VB & VBA Settings.)

Quote:
> I was wondering, how easy is it to do Find & Replace within the
> windows registry with visual basic.

> Bascially, there are several string values which need changing from
> e.g AAA to BBB under the HKCU\Software\VB & VBA Settings in several
> folders.

> I know how to do getsettings and savesettings etc, but not to search
> and then change.

> Any ideas on how to this task with VB?

> Thanks



Sat, 03 Mar 2012 22:36:38 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Registry - search & replace

2. Registry Key renaming with VBScript and Regedit

3. Find & Replace Problem - ACC97

4. Find& replace one by one

5. Find & Replace using input box

6. FIND & REPLACE

7. Multiple find & replace

8. Find&replace-code

9. find & Replace with wild cards and patterns

10. find/replace on headers&footers

11. Excel macro to find&replace in MSWord

12. Find&Replace Tab

 

 
Powered by phpBB® Forum Software