is there a way to restart a juce app, i have all i need to do an update of my app, the file is in place, now i need to restart, i know some win32 specific ways, but is there some universal way to do this ?
You can start it with File::launchAsProcess?
but can i stop the whole application and start it again ? i now i can spawn another copy of my own process and exit the original one, but that will not work as i don’t allow more then one instance of my app.
i’m talking about how any application restarts itself after an update.
I had written this code few months back and it had worked then but for some reason i don’t use it, it’s in Carbon so it would work on Macintosh.
you can use this to kill the application
bool
KillApplication (const char* ApplicationName) // application name without extension(without .app)
{
OSErr err = 0, otherErr = 0;
ProcessSerialNumber psn ;
psn.highLongOfPSN = 0;
psn.lowLongOfPSN = kNoProcess;
err = GetNextProcess(&psn);
do
{
CFStringRef name;
otherErr = CopyProcessName(&psn, &name);
if(otherErr != 0)
return -1;
CFStringRef processName = CFStringCreateWithCString(NULL, ApplicationName, NULL); ;
CFComparisonResult result = CFStringCompare(processName, name, 0);
if(result == 0)
{
KillProcess (&psn);
break;
}
err = GetNextProcess(&psn);
}while(err == 0);
return false;
}
and then call " File::launchAsProcess"
i mean something like this: http://msdn.microsoft.com/en-us/library/system.windows.forms.application.restart.aspx
modify your code so that you allow a second instance IF there is a specific command line option, and the second instance tells the previous instance to exit.
please go through these links, you might find them useful
http://vgable.com/blog/2008/10/05/restarting-your-cocoa-application/
http://www.cocoabuilder.com/archive/message/cocoa/2005/6/17/139224
http://archives.devshed.com/forums/bsd-93/restarting-application-automatically-961772.html