[英]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.