How to redirect registry access of a dll loaded by my program

Posted by dummzeuch on Stack Overflow See other posts from Stack Overflow or by dummzeuch
Published on 2010-06-18T07:16:56Z Indexed on 2010/06/18 7:23 UTC
Read the original article Hit count: 262

Filed under:
|
|

I have got a dll that I load in my program which reads and writes its settings to the registry (hkcu). My program changes these settings prior to loading the dll so it uses the settings my program wants it to use which works fine.

Unfortunately I need to run several instances of my program with different settings for the dll. Now the approach I have used so far no longer works reliably because it is possible for one instance of the program to overwrite the settings that another instance just wrote before the dll has a chance to read them.

I haven't got the source of the dll in question and I cannot ask the programmer who wrote it to change it.

One idea I had, was to hook registry access functions and redirect them to a different branch of the registry which is specific to the instance of my program (e.g. use the process id as part of the path). I think this should work but maybe you have got a different / more elegant.

In case it matters: I am using Delphi 2007 for my program, the dll is probably written in C or C++.

© Stack Overflow or respective owner

Related posts about delphi

Related posts about registry