Forum > General
Restart application
Emerson:
Hi!
I need a function that terminates the application and then runs it again.
Does anyone have this algorithm that can help me?
Emerson:
You can leave it personal, I found it here. Thank you very much!
https://forum.lazarus.freepascal.org/index.php/topic,26847.msg165406.html#msg165406
MarkMLl:
Note the caveats about path etc. in that example. In practice you're likely to find that anything like this has OS-specific elements... please remember to ALWAYS say what OSes you're interested in and what FPC/Lazarus version you're running with ANY question.
Having got that out of the way, I'd point out an issue that's probably universal. The "parent" program might be processing files and/or listening for socket connections etc., you might have problems getting a child to inherit all of that particularly since ports (i.e. TCP/UDP) might require a delay before being re-used. I'm not saying that you'll have definite problems there, just highlighting the potential.
MarkMLl
Ten_Mile_Hike:
Years ago in Windows ( "7" I think) I used this kludge
1. Upon exiting my application I had my program output a batch file
2. My program executed the batch file.
3. The application finished terminating
4. The now running batch file looped until it found that my program wasn't running any longer
5. My batch file then executed the program that originaly created it
Mr.Madguy:
At least on Windows it can't be done without external application. You launch some sort of update program. You should provide some soft of information about your program's process, so update program would be able to wait for it to terminate (like WaitForSingleObject(Process)). Then external program updates your main program, relaunches it and terminates.
Navigation
[0] Message Index
[#] Next page