Is it possible to restart my application from within my application?
-
Is it possible to restart my dialog application from within or should I create an outside object to close it and then to start it again?
If your application lives just in an *.exe there isn't a possibility, but if in a *.dll there is. You load your own .dll from an *.exe, when the *.dll attaches to the *.exe the reason for call in DllMain is DLL_PROCESS_ATTACH. Depending upon value of dwReason you can start your code. If your process starts, your *.exe is shown in the task manager (with the *.dll linked to it), and it can be killed from there. In this case your DllMain gets called again with reason DLL_PROCESS_DETACH. From here you have to do a ShellExecute on your *.exe, and your process with the linked *.dll starts again. Peter Molnar
-
Is it possible to restart my dialog application from within or should I create an outside object to close it and then to start it again?
You basically need two exe files, say, A and B. Now you want to restart A "within" A, you simply let A do the following: 1, Launch B via a call to
::ShellExecute
. 2, Terminate itself. At this point B has been launched and A has been terminated. Now, what B does are the following: 1, Wait a few seconds by using a timer. This is usually necessary because A may need some time to cleanup, i.e., de-allocate resources, clean files, whatever, etc. 2, Launch A via a call to::ShellExecute
. 3, Terminate itself. So now your A is "restarted". -
Is it possible to restart my dialog application from within or should I create an outside object to close it and then to start it again?
Yes, few solutions awailable: 1) External executable, when given control restarts app. 2) Create batch file that restarts application with flag delete on close, execute it, and exit application. 3) Same executable, or new version of exec or exe making copy of itself, with when started with "reboot" command option, waits for executer to close, places itself into original directory, and re-starts itself. I used to use (1), now I use (3) for self-update.