Click here to Skip to main content
15,885,546 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: C++ Question Pin
Niklas L7-Jun-11 2:26
Niklas L7-Jun-11 2:26 
AnswerRe: C++ Question Pin
Stefan_Lang7-Jun-11 2:00
Stefan_Lang7-Jun-11 2:00 
GeneralRe: C++ Question Pin
Software20077-Jun-11 5:03
Software20077-Jun-11 5:03 
QuestionMiddleware/CORBA Data Field Inheritance Pin
rkeeler786-Jun-11 13:11
rkeeler786-Jun-11 13:11 
QuestionSuddenly Exe is not running Pin
pix_programmer6-Jun-11 2:16
pix_programmer6-Jun-11 2:16 
AnswerRe: Suddenly Exe is not running Pin
Alan Balkany6-Jun-11 9:21
Alan Balkany6-Jun-11 9:21 
AnswerRe: Suddenly Exe is not running Pin
Stefan_Lang7-Jun-11 2:17
Stefan_Lang7-Jun-11 2:17 
GeneralRe: Suddenly Exe is not running Pin
pix_programmer7-Jun-11 2:49
pix_programmer7-Jun-11 2:49 
Stefan_Lang wrote:
- have you applied any patches?


For other questions my answer is 'no'.

I didn't understand what is "patches". I've created Mutex. But it was working fine with Mutex. Here's my Mutex code:

BOOL Cflash_mfcApp::InitInstance()
{
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

	AfxEnableControlContainer();


#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL

#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif
	// Standard initialization
	// If you are not using these features and wish to reduce the size
	// of your final executable, you should remove from the following
	// the specific initialization routines you do not need
	// Change the registry key under which our settings are stored
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));





	Default();
	FileRead();
	char CurrentPath[_MAX_PATH];
	Gen ObjGen;
	ObjGen.GetCurrentPath(CurrentPath);
	ostringstream OCurrPath;
	OCurrPath.str("");
	OCurrPath << CurrentPath<<"\\";
	CurrPath="";
	CurrPath = OCurrPath.str();


	if(NULL != ::CreateMutex(NULL, TRUE,_T("CSingleInstanceApp")))
	{
		long dwError = ::GetLastError();
		if(dwError == ERROR_ALREADY_EXISTS)
		{
			//	MessageBox(NULL,L"You are Already Running Application.",L"ERROR!!",MB_OK);
			EndDialog(NULL,IDOK);	
			return FALSE;
		}
		else
		{
			/*Update *ObjUpdate=new Update;
			ObjUpdate->Create(IDD_UPDATE,this);
			ObjUpdate->ShowWindow(SW_SHOW);*/


			if(!ObjGen.OnCheckConnection())
			{
				CError ObjCError;
				m_pMainWnd = &ObjCError;
				INT_PTR nResponse = ObjCError.DoModal();
				//ObjCError.DoModal();
				return 0;
			}


			ostringstream oexe;
			oexe << "cmd /c del "<<glo_exe_name<<"_* /f/q/a";
			WinExec((LPCSTR)oexe.str().c_str() , SW_HIDE);

			Update ObjUpdate;
			m_pMainWnd = &ObjUpdate;
			INT_PTR nResponse = ObjUpdate.DoModal();

			AfxGetApp()->m_pMainWnd = NULL;

			
		TerminateThread(Retry::ThreadExec, 0);
		TerminateThread(TransferringForm::ThreadExec, 0) ;
		TerminateThread(TransferringForm::ThreadExec1, 0) ;

		ostringstream os;
		os << "cmd /c taskkill /F /IM \"" << glo_exe_name <<"\" /T";
		string to=os.str();
		WinExec((LPCSTR)to.c_str() , SW_HIDE);
		}

		
	}


	/*Cflash_mfcDlg dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();

	if (nResponse == IDOK)
	{
	IndexForm ObjIndexForm;
	m_pMainWnd = &ObjIndexForm;
	ObjIndexForm.DoModal();
	}
	else if (nResponse == IDCANCEL)
	{


	}*/



	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}


But my app was working fine with this code.
GeneralRe: Suddenly Exe is not running Pin
Stefan_Lang7-Jun-11 2:55
Stefan_Lang7-Jun-11 2:55 
GeneralRe: Suddenly Exe is not running Pin
pix_programmer7-Jun-11 3:00
pix_programmer7-Jun-11 3:00 
GeneralRe: Suddenly Exe is not running Pin
Stefan_Lang7-Jun-11 3:26
Stefan_Lang7-Jun-11 3:26 
QuestionDisplay CBitmap into CStatic [modified] Pin
_Flaviu6-Jun-11 1:54
_Flaviu6-Jun-11 1:54 
AnswerRe: Display CBitmap into CStatic Pin
Roger Allen6-Jun-11 2:24
Roger Allen6-Jun-11 2:24 
GeneralRe: Display CBitmap into CStatic Pin
_Flaviu6-Jun-11 2:39
_Flaviu6-Jun-11 2:39 
QuestionCStatic ModifyStyle Pin
_Flaviu6-Jun-11 1:00
_Flaviu6-Jun-11 1:00 
AnswerRe: CStatic ModifyStyle Pin
The_Inventor6-Jun-11 20:41
The_Inventor6-Jun-11 20:41 
AnswerRe: CStatic ModifyStyle Pin
Code-o-mat7-Jun-11 22:59
Code-o-mat7-Jun-11 22:59 
QuestionHow to use tcp keepalive to check the client is alive? Pin
wangningyu4-Jun-11 23:23
wangningyu4-Jun-11 23:23 
AnswerRe: How to use tcp keepalive to check the client is alive? Pin
Code-o-mat5-Jun-11 22:55
Code-o-mat5-Jun-11 22:55 
GeneralRe: How to use tcp keepalive to check the client is alive? Pin
Emilio Garavaglia6-Jun-11 3:41
Emilio Garavaglia6-Jun-11 3:41 
GeneralRe: How to use tcp keepalive to check the client is alive? Pin
Code-o-mat6-Jun-11 3:58
Code-o-mat6-Jun-11 3:58 
AnswerRe: How to use tcp keepalive to check the client is alive? Pin
jschell6-Jun-11 9:07
jschell6-Jun-11 9:07 
Questionmysql error and UNICODE Pin
includeh104-Jun-11 18:44
includeh104-Jun-11 18:44 
AnswerRe: mysql error and UNICODE Pin
Code-o-mat5-Jun-11 22:26
Code-o-mat5-Jun-11 22:26 
QuestionIs it possible to set another visual style only for my application [modified] Pin
Cold_Fearing_Bird4-Jun-11 16:59
Cold_Fearing_Bird4-Jun-11 16:59 

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.