[英]How to terminate a running program in c++
我已经用C ++编写了一个程序,我称之为
system("C:\xampp\xampp-control.exe");运行xampp控制面板。 当我在编译后运行程序时,它运行得很顺利,除了我编写的程序仍在运行。 XAMPP控制面板启动后,我想终止该程序。 可能会做什么? 非常感谢任何帮助。
您可以用exec
替换您的应用程序。
// Note: this waits for the exectued program to finish
// before the call to `system()` returns.
system("C:\xampp\xampp-control.exe");
// You can replace the current processes with the one you
// are starting like this.
execl("C:\xampp\xampp-control.exe", "xampp-control.exe");
// If this returns the applicaion failed to start.
std::cerr << "Failed to start application\n";
exit(1);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.