How to restart MFC application from within itself
-
Hello friends... I am working with vc++6.Now i wanted to restart my MFC application from within itself.How can i make it possible. Please help me Thanks
Can you more explain restart my MFC application from within itself?
WhiteSky
-
Hello friends... I am working with vc++6.Now i wanted to restart my MFC application from within itself.How can i make it possible. Please help me Thanks
There is no in build function to do that i believe. One approach could be starting a new instance of the current application and then exit the current instance (some more inteligence can be given to the application through the command line parameters like to wait till the parent application has cleaned-up the resource and exited properly before initializing the new instance).
-
Hello friends... I am working with vc++6.Now i wanted to restart my MFC application from within itself.How can i make it possible. Please help me Thanks
Use Create Process. I have tested it with a dialog based app. Maybe you must use some startup time delay to wait until the calling application is closed. For more information about CreateProcess have alook in the MSDN. void CRestart_selfDlg::OnButtonRestart() { STARTUPINFO m_StartupInfo; PROCESS_INFORMATION m_ProcessInformation; ZeroMemory(&m_StartupInfo, sizeof(STARTUPINFO)); ZeroMemory(&m_ProcessInformation, sizeof(PROCESS_INFORMATION)); char* szPrgPathName = "\"restart_self.exe\""; CreateProcess ( NULL , szPrgPathName // the commandline options , (LPSECURITY_ATTRIBUTES)NULL , (LPSECURITY_ATTRIBUTES)NULL , FALSE , CREATE_NEW_CONSOLE , NULL , NULL , &m_StartupInfo , &m_ProcessInformation) ; DWORD dwLastError = GetLastError(); // for test only // close now the dialog based application OnOK(); // should work in view based application, not tested // theApp.CloseAllDocuments(TRUE); }
-
Vinod Moorkkan wrote:
Now i wanted to restart my MFC application from within itself.
To start an EXE in another process, you can use system( "filename"). Its prototype should be included with any MFC-Program or you can include for it. Your old aplication then simply terminates.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.
prefer
::ShellExecute()
or::CreateProcess()
thansystem()
Don't know where to start ?
Refer the Forums Guidelines and ask a friend -
There is no in build function to do that i believe. One approach could be starting a new instance of the current application and then exit the current instance (some more inteligence can be given to the application through the command line parameters like to wait till the parent application has cleaned-up the resource and exited properly before initializing the new instance).
you here !? welcome back, and happy new year :rose::cool: ps: arrange your sig and close the opened html tag ;)
Don't know where to start ?
Refer the Forums Guidelines and ask a friend -
you here !? welcome back, and happy new year :rose::cool: ps: arrange your sig and close the opened html tag ;)
Don't know where to start ?
Refer the Forums Guidelines and ask a friendtoxcct wrote:
welcome back, and happy new year
Thanks a tonn toxcct. glad to see you still remember ! Wish you the same and all the best for 2007 :rose: Thought of doing something good for this 07 and ended up back here in CP :cool:
toxcct wrote:
ps: arrange your sig and close the opened html tag
still in search for a new sig for the new year ;)
-
prefer
::ShellExecute()
or::CreateProcess()
thansystem()
Don't know where to start ?
Refer the Forums Guidelines and ask a friendCongratulation new icon its nice :-D
WhiteSky
-
toxcct wrote:
welcome back, and happy new year
Thanks a tonn toxcct. glad to see you still remember ! Wish you the same and all the best for 2007 :rose: Thought of doing something good for this 07 and ended up back here in CP :cool:
toxcct wrote:
ps: arrange your sig and close the opened html tag
still in search for a new sig for the new year ;)
of course i remember you, you were one of the 1st who left me a message in my "CP Blog"... btw, i wish you to fine your new sig... lol
Don't know where to start ?
Refer the Forums Guidelines and ask a friend -
Congratulation new icon its nice :-D
WhiteSky
WhiteSky wrote:
Congratulation new icon its nice
thanks :cool::rose:
Don't know where to start ?
Refer the Forums Guidelines and ask a friend -
Hello friends... I am working with vc++6.Now i wanted to restart my MFC application from within itself.How can i make it possible. Please help me Thanks
Use can use CreateProcess() to start ur MFC application and then exit ur current exe. :)
-
Use can use CreateProcess() to start ur MFC application and then exit ur current exe. :)
Thank you..friends.. I used CreateProcess it working..