主动宣告setProcessState(QProcess::NotRunning)
 
或者在堆上new一个QProcess。
 
 
出处:
 https://stackoverflow.com/questions/33874243/qprocessstartdetached-but-hide-console-window

I had exactly the same problem, and could not solve it in a clean way. I have found 2 options:

  1. Hacky way: Subclass QProcess and call setProcessState(QProcess::NotRunning); after starting the process. This will prevent the destructor to terminate the process. But it relies on an implementation detail of QProcess
  2. Create a memory leak: Dynamically create the QProcess on the heap, but never delete it, and thus never invoke its destructor

{
    QProcess *process = new QProcess;
    process->start("taskkill", QStringList() << "/f" << "/im" << "My Service.exe");
}

 

相关文章:

  • 2022-12-23
  • 2021-07-19
  • 2021-12-18
  • 2021-10-02
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-19
  • 2022-12-23
  • 2021-09-20
  • 2021-12-12
  • 2021-08-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案