3

I`m creating a cast of dlls that shares a single dll.

The shared lib has a Singleton.

When running, some os loaded libs make new instances of my singleton. How can I force all libs and programs using my dll use ALWAYS one instance of my singleton?

3

1 Answer 1

3

You can't just share your singleton instance between several processes. but you can use shared memory for this purpose:

The following example demonstrates how the DLL entry-point function can use a file-mapping object to set up memory that can be shared by processes that load the DLL. The shared DLL memory persists only as long as the DLL is loaded. Applications can use the SetSharedMem and GetSharedMem functions to access the shared memory.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms686958(v=vs.85).aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.