how can single instance app restart itself?
Is there any way for a "single instance" app to restart itself via CreateProcess()?
I have an app that uses a Mutex as it must ensure only one instance of itself is allowed to run. It is an MFC MDI single document app that "reinitializes" then "restarts" itself after its user reconfigures its database path. It does this by closing its main document and reloading it, but, unfortunately, it does not reinitialize all of itself. The app fails to reinitialize Crystal Reports which in turn uses an ODBC DSN to show database reports. Even though the database pointer changes in the text of the DSN file, there seems to be no way to tell Crystal Reports to reload its DSN.
The app works fine if the user exits the app and then restarts it.
I read the FAQ "How can I start a process" though it is unclear to me how to start a process from a process that uses a mutex to ensure only one copy of itself runs. Any ideas?
Re: how can single instance app restart itself?
Quote:
Originally posted by RNEELY
Is there any way for a "single instance" app to restart itself via CreateProcess()?
I think this is not really required. If you do this, I think it is going to be only a workaround for the issue.
Quote:
It does this by closing its main document and reloading it, but, unfortunately, it does not reinitialize all of itself. The app fails to reinitialize Crystal Reports which in turn uses an ODBC DSN to show database reports. Even though the database pointer changes in the text of the DSN file, there seems to be no way to tell Crystal Reports to reload its DSN.
There may be some bug here. You may want to investigate that first. It is kinda ugly to kill the app and relaunch it just for the heck of it.
Quote:
The app works fine if the user exits the app and then restarts it.
I read the FAQ
"How can I start a process" though it is unclear to me how to start a process from a process that uses a mutex to ensure only one copy of itself runs. Any ideas?
I would still encourage you to find the exact problem instead :)