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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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