Restarting a running program
-
Hi, how to I restart my program from its own. Now I do it with a batch file, it looks like this: 1) process starts a batch-file 2) process stops 3) batchfile waits 2 seconds 4) batchfile starts the process again Has anybody a better solution ? Thank you, Mario
-
Hi, how to I restart my program from its own. Now I do it with a batch file, it looks like this: 1) process starts a batch-file 2) process stops 3) batchfile waits 2 seconds 4) batchfile starts the process again Has anybody a better solution ? Thank you, Mario
ShellExecute(NULL,"open",MyAppPath,"-r","",SW_SHOW ); PostMessage(hWnd,WM_QUIT,NULL,NULL);
It's not a bug, it's an undocumented feature.
suhredayan@omniquad.commessenger :suhredayan@hotmail.com
-
ShellExecute(NULL,"open",MyAppPath,"-r","",SW_SHOW ); PostMessage(hWnd,WM_QUIT,NULL,NULL);
It's not a bug, it's an undocumented feature.
suhredayan@omniquad.commessenger :suhredayan@hotmail.com
suhredayan® wrote: ShellExecute(NULL,"open",MyAppPath,"-r","",SW_SHOW ); whats -r ???
God is Real, unless declared Integer.
-
ShellExecute(NULL,"open",MyAppPath,"-r","",SW_SHOW ); PostMessage(hWnd,WM_QUIT,NULL,NULL);
It's not a bug, it's an undocumented feature.
suhredayan@omniquad.commessenger :suhredayan@hotmail.com
PostQuitMessage(NULL) would be the better choice then PostMessage(hWnd,WM_QUIT,NULL,NULL); jitendra
-
PostQuitMessage(NULL) would be the better choice then PostMessage(hWnd,WM_QUIT,NULL,NULL); jitendra
Jitendra gangwar wrote: PostQuitMessage(NULL) would be the better choice then PostMessage(hWnd,WM_QUIT,NULL,NULL); If PostQuitMessage(NULL) is called from within a userinterface thread which is one of the many, within your application. It just posts a WM_QUIT message to the thread’s message queue and returns immediately; the function simply indicates to the system that the thread is requesting to quit at some time in the future.
It's not a bug, it's an undocumented feature.
suhredayan@omniquad.commessenger :suhredayan@hotmail.com
-
suhredayan® wrote: ShellExecute(NULL,"open",MyAppPath,"-r","",SW_SHOW ); whats -r ???
God is Real, unless declared Integer.
Mr.Prakash wrote: whats -r ??? Hi Prakash, Missed to explain the paramaters. Can omit "-r", which can be otherwise used to indicate the application was restarted. Please check my signature. :-D
It's not a bug, it's an undocumented feature.
suhredayan@omniquad.commessenger :suhredayan@hotmail.com
-
Jitendra gangwar wrote: PostQuitMessage(NULL) would be the better choice then PostMessage(hWnd,WM_QUIT,NULL,NULL); If PostQuitMessage(NULL) is called from within a userinterface thread which is one of the many, within your application. It just posts a WM_QUIT message to the thread’s message queue and returns immediately; the function simply indicates to the system that the thread is requesting to quit at some time in the future.
It's not a bug, it's an undocumented feature.
suhredayan@omniquad.commessenger :suhredayan@hotmail.com
suhredayan® wrote: If PostQuitMessage(NULL) is called from within a userinterface thread which is one of the many, within your application. It just posts a WM_QUIT message to the thread’s message queue and returns immediately; the function simply indicates to the system that the thread is requesting to quit at some time in the future. If PostQuitMessage(NULL) is called from within a userinterface thread which is one of the many, within your application. It just posts a WM_QUIT message to the thread’s message queue and returns immediately; the function simply indicates to the system that the thread is requesting to quit at some time in the future. But according to MSDN -- Remarks The WM_QUIT message is not associated with a window and therefore will never be received through a window's window procedure. It is retrieved only by the GetMessage or PeekMessage functions. Do not post the WM_QUIT message using the PostMessage function; use PostQuitMessage.
-
suhredayan® wrote: If PostQuitMessage(NULL) is called from within a userinterface thread which is one of the many, within your application. It just posts a WM_QUIT message to the thread’s message queue and returns immediately; the function simply indicates to the system that the thread is requesting to quit at some time in the future. If PostQuitMessage(NULL) is called from within a userinterface thread which is one of the many, within your application. It just posts a WM_QUIT message to the thread’s message queue and returns immediately; the function simply indicates to the system that the thread is requesting to quit at some time in the future. But according to MSDN -- Remarks The WM_QUIT message is not associated with a window and therefore will never be received through a window's window procedure. It is retrieved only by the GetMessage or PeekMessage functions. Do not post the WM_QUIT message using the PostMessage function; use PostQuitMessage.
PostQuitMessage(0); form within another UI Thread will not exit the application. But PostMessage(hWnd,WM_QUIT,0,0); will be caught by the underlying handlers and the application will get exited for sure, provided its the handle to the main window. so i feel suhredyan's method atleast ensures that the application is exited.
-
PostQuitMessage(0); form within another UI Thread will not exit the application. But PostMessage(hWnd,WM_QUIT,0,0); will be caught by the underlying handlers and the application will get exited for sure, provided its the handle to the main window. so i feel suhredyan's method atleast ensures that the application is exited.
I am agree with you. Thanks for correcting me.
-
I am agree with you. Thanks for correcting me.