First of all, the function only deals with a string. It has nothing to do with the registry. You read the ValueData into a string, replace the substring and then write the ValueData back.

Second, please use the proper terminology for the the registry items. Do not confuse Keys with ValueNames and ValueData. See the FAQ:

Topic: Registry
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.