does anyone here know of a quick and easy way to restart the current process? I mean, let the process close, and when it closes, restart it again?
the only thing that I can think of is injecting a thread into another process which waits for the program (the injector) to close, before it calls CreateProcess or the like to start it again. this is rather dirty, and would involve injecting into a process that I know will always exist, which will likely be a process that is vital to the operation of Windows (like Explorer.exe). this could also lead to problems, since not all of the APIs used for process injection are supported across platforms. for example, some of them do not exist in Win9x. I suppose I could write my own implementations of them, but I dunno, it just seems dirty to me. if it's the only option I'll have to go for it, but there has to be another way.
any ideas or suggestions are appreciated. thanks in advance.
Sure, you should be able to do something like this: create a process which executes the current process again, and then exits itself. You shouldn't need to "inject a thread into another process" . . . .
I'm not sure how this could be done in Windows, but in Linux, you can do it with something as simple as this.
thanks dwks, that works perfectly. :)
now, if I could only find where execvp is declared to silence a warning it would be perfect. execvp is listed at msdn, but there is no description for it :rolleyes: .
EDIT: nvm, I just added my own prototype for it:
int execvp(const char *, const char **);
Why not just start a new instance of your app and let the old one exit?