C ++的"系统"无需等待的(Win32) [英] C++'s "system" without wait (Win32)

查看:101
本文介绍了C ++的"系统"无需等待的(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);
}

但不等待updater.exe来完成。否则,因为它正在运行,我不能没有我的主程序。因此,如何执行updater.exe,并立即退出?我知道与叉* nix的方式等,如何做到这一点在Windows?

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?

推荐答案

使用的的CreateProcess(),它异步运行。然后,你将只需要保证updater.exe可以写入到原来的EXE,您可以通过等待或重试,直到原有的工艺已经结束做。 (当然了宽限期间隔)。

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.)

这篇关于C ++的"系统"无需等待的(Win32)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆