Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++'s "system" without wait (Win32)

I have got a program which checks if there's a version update on the server. Now I have to do something like

if(update_avail) {
    system("updater.exe");
    exit(0);
}

but without waiting for "updater.exe" to complete. Otherwise I can't replace my main program because it is running. So how to execute "updater.exe" and immediately exit? I know the *nix way with fork and so on, how to do this in Windows?

like image 349
gorootde Avatar asked Jul 20 '26 21:07

gorootde


1 Answers

Use CreateProcess(), it runs asynchronously. Then you would only have to ensure that updater.exe can write to the original EXE, which you can do by waiting or retrying until the original process has ended. (With a grace interval of course.)

like image 145
Prof. Falken Avatar answered Jul 22 '26 11:07

Prof. Falken



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!