Click here to Skip to main content
15,912,072 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How do I prevent multiple instances of my program Pin
Ernest Laurentin6-Mar-08 5:39
Ernest Laurentin6-Mar-08 5:39 
GeneralRe: How do I prevent multiple instances of my program Pin
cgb1436-Mar-08 6:01
cgb1436-Mar-08 6:01 
GeneralActiveX question Pin
dolphinhk6-Mar-08 5:04
dolphinhk6-Mar-08 5:04 
GeneralRe: ActiveX question Pin
led mike6-Mar-08 5:54
led mike6-Mar-08 5:54 
GeneralRe: ActiveX question Pin
Mark Salsbery6-Mar-08 6:23
Mark Salsbery6-Mar-08 6:23 
Generalhehehe well he did ask [modified] Pin
led mike6-Mar-08 9:06
led mike6-Mar-08 9:06 
GeneralRe: hehehe well he did ask Pin
Mark Salsbery6-Mar-08 9:14
Mark Salsbery6-Mar-08 9:14 
QuestionLoosing interfaces function in Single Instance Application with a Class having multiple heritance Pin
ochoteau6-Mar-08 5:00
ochoteau6-Mar-08 5:00 
Hi all,

How to create an Application which have a singleton class which herit form 3 other interface class (so with pure virtual functions), without loosing reference to these interface functions ?

My problem is that I am lossing reference to vftable(__vfptr) between instances, so I cannot access to my interfaces in another instance of the application.

More about this problem :
1 - I launch "MyClass.exe start" => OK "MyClass.exe" is running ...
2 - I launch "MyClass.exe configure" => access violation is raised, because can't access to MyClass->Configure().

NB: this problem not occur if I make -2- then -1-
And although I call Configure() inside Start() it's working well.


My implementation code is :
<br />
#include "MyClass.h"<br />
#pragma data_seg("MyShared")<br />
	MyClass*	MyClass::m_instance = 0; // The MyClassUnique instance<br />
#pragma data_seg()<br />
#pragma comment(linker, "/section:MyShared,rws") <br />
<br />
int main(int argc, char *argv[])<br />
{<br />
	// Retrieve the MyClassUnique instance<br />
	MyClass* Me= MyClass::Instance();<br />
	if(argc==2)<br />
	{<br />
		if(strcmp(argv[1],"start")==0)<br />
		{<br />
			MyClass->Start(); // OK MEMBER FUNCTION<br />
			return 1;<br />
		}<br />
<br />
		if(strcmp(argv[1],"stop")==0)<br />
		{<br />
			C3STrace(C3S_TRACE_DEBUG, C3S_TRACE_INFO, "MAILNOTIFIER_STOP");<br />
			MyClass->Stop();  // OK MEMBER FUNCTION<br />
			return 2;<br />
		}<br />
<br />
		if(strcmp(argv[1],"configure")==0)<br />
		{<br />
			MyClass->Configure(); // KO WHEN CALLED IN ANOTHER INSTANCE<br />
			// Configure is one of the virtual function of one interface<br />
			// I have an excetion acess violation at 0xXXXXXX reading 0xYYYYYY<br />
			return 3;<br />
		}<br />
	}<br />
	return 0;<br />
}<br />
<br />
-------------------------------------<br />
class MyClass: public Interface1, public Interface2, public Interface3<br />
{<br />
     ....<br />
     static MyClass m_instance;<br />
     static MyClass* Instance();<br />
     virtual void Configure();<br />
}<br />
-------------------------------------<br />
MyClass* MyClass::Instance()<br />
{ <br />
	if( m_instance == NULL )<br />
		m_instance = new MyClass(); <br />
	return m_instance;<br />
}<br />
--------------------------------------<br />
void MyClass::Configure()<br />
{<br />
     // do configuration job<br />
}<br />
--------------------------------------<br />


Regards,
Olivier.
GeneralRe: Loosing interfaces function in Single Instance Application with a Class having multiple heritance Pin
Member 75496024-Mar-08 10:50
Member 75496024-Mar-08 10:50 
GeneralRegistering a Notification Handler with an Active Directory Server. Pin
johnalek6-Mar-08 3:58
johnalek6-Mar-08 3:58 
QuestionWhat is cl_login in MFC? Pin
Nikesh Jagtap6-Mar-08 3:10
Nikesh Jagtap6-Mar-08 3:10 
AnswerRe: What is cl_login in MFC? Pin
Hamid_RT9-Mar-08 1:06
Hamid_RT9-Mar-08 1:06 
Generalmemory usage keeps on increasing Pin
jalsa G6-Mar-08 2:09
jalsa G6-Mar-08 2:09 
GeneralRe: memory usage keeps on increasing Pin
CPallini6-Mar-08 2:14
mveCPallini6-Mar-08 2:14 
GeneralRe: memory usage keeps on increasing Pin
toxcct6-Mar-08 2:18
toxcct6-Mar-08 2:18 
GeneralRe: memory usage keeps on increasing Pin
jalsa G6-Mar-08 2:26
jalsa G6-Mar-08 2:26 
GeneralRe: memory usage keeps on increasing Pin
toxcct6-Mar-08 2:39
toxcct6-Mar-08 2:39 
QuestionRe: memory usage keeps on increasing Pin
CPallini6-Mar-08 2:54
mveCPallini6-Mar-08 2:54 
QuestionWhy this code doesn't crash? Pin
ComplexLifeForm6-Mar-08 1:51
ComplexLifeForm6-Mar-08 1:51 
AnswerRe: Why this code doesn't crash? Pin
CPallini6-Mar-08 1:59
mveCPallini6-Mar-08 1:59 
AnswerRe: Why this code doesn't crash? Pin
toxcct6-Mar-08 2:17
toxcct6-Mar-08 2:17 
GeneralRe: Why this code doesn't crash? Pin
CPallini6-Mar-08 2:22
mveCPallini6-Mar-08 2:22 
GeneralRe: Why this code doesn't crash? Pin
toxcct6-Mar-08 2:25
toxcct6-Mar-08 2:25 
GeneralRe: Why this code doesn't crash? Pin
CPallini6-Mar-08 2:45
mveCPallini6-Mar-08 2:45 
GeneralRe: Why this code doesn't crash? Pin
ComplexLifeForm6-Mar-08 2:23
ComplexLifeForm6-Mar-08 2:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.