tags:

views:

119

answers:

3

I am trying to share some data across DLLs in a project which has an extremely complicated dependency structure (numberous DLLs).

I want to be able to associate a key with some data in one part of the application, and then extract that data by supplying the appropriate key in some other part of the app. In a way, one can say that I looking for something that is similar to Java's System.setProperty()/getProperty().

I was sure that the Process APIs would give me some access to a process-wide buffer, but I had no lack. Any ideas?

(I know that the clean solution is to introduce a new DLL and to link it properly to the existing DLLs. Unfortunately, this type of solution is beyond the mandate of my team).

A: 

You don't need fancy API's for that. Windows has a much older API precisely for this kind of stuff. These things are known as "atoms". You'd use functions as AddAtom and FindAtom. By default atoms are process-wide.

MSalters
Here's a link to an article that has a wrapper class for use of atoms.http://www.codeproject.com/KB/winsdk/win32Atom_Wrapper.aspx
zooropa
A: 

To be clear here there is one exe with multiple DLL's in only one process but multiple modules. So you aren't looking for inter-process communications.

In answer I see two strategies:

  1. use Windows API atoms which are slightly limited (basically only string data) which can work within or between processes.

  2. If you write a DLL which contains your speculated SetProperty/getproperty functionality you don't have to compile ALL the other DLL's again (which is presumably what is beyond your team's specification) - you only need to recompile those DLL's which are currently using your new features (set/getproperty) (which is presumably within your teams power). So this seems a direct and powerful solution.

Elemental
A: 

You can create a DLL for this task, though is responsible for managing the data cache for you. There is an implementation using ATL templates that have all the resources of cache ready.

Use CBlobCache class as base class, being more or less like this:

class CCache : public CBlobCache, CPerfStatClass>
{
public:
 CCache()
 {
   CBlobCache::Initialize(NULL);
 }
}  YourCache;

More information and includes see ATLServer CodePlex site.

lsalamon