Singleton: DLL compartida de C++
Frecuentes
Visto 1,150 veces
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 SIEMPRE one instance of my singleton?
1 Respuestas
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
Respondido 28 ago 12, 14:08
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas c++ c windows dll shared-libraries or haz tu propia pregunta.
You should probably look up the term "shared memory". - Some programmer dude
posible duplicado de ¿Se puede compartir una clase Singleton dentro de una DLL entre procesos? - Bo Persson
Make it a windows service or a COM server/service - Indy9000