QT 启动与关闭外部程序

QT 启动与关闭外部程序,第1张

启动

QString filepath = QDir::currentPath()

    QString fullpath = filepath+"\\pp\\dist\\start"

    QString title = fullpath+"\\main.exe"

    title = title.replace("/","\\")

    fullpath = fullpath.replace("/","\\")

   袜答 QProcess p(this)

    p.setWorkingDirectory(fullpath)

    p.start("cmd", QStringList()<<"/c"<<"start main.exe")

    p.waitForStarted()

    p.waitForFinished()

关闭

    QProcess p(this)

    p.setWorkingDirectory(fullpath)

   庆洞 p.start("告差慧cmd", QStringList()<<"/c"<<"taskkill /f /t /im main.exe")

    p.waitForStarted()

    p.waitForFinished()

进洞耐程关橡谨闭纳如春外部程序

QString KillStr = "taskkill /f /im main.exe"

QProcess *Process = new QProcess(this)

Process->start(KillStr)


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12309076.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存