在 Qt/C++ 中获取 QProcess 的可执行文件名称
Getting the executable name of a QProcess in Qt/C++
是否有可能找出 QProcess 对象的可执行文件 name/path?到现在我只知道有 QProcess::pid() 用于标识进程。到目前为止,搜索 Qt 文档还没有找到有用的解决方案。
提前致谢!
示例
int main() {
QProcess* p = new QProcess(this);
p->start("C:\test.exe");
func(p);
return 0;
}
void func (QProcess* p)
{
qDebug() << "The application name of the app with pid" << p->pid() << "is" << p->name(); // name() doesn't exist, that's where I need help
}
尝试使用 QProcess 对象的 program()
方法,像这样:
QProcess process(this);
process.start("calc.exe");
qDebug() << process.program();
process.waitForFinished();
是否有可能找出 QProcess 对象的可执行文件 name/path?到现在我只知道有 QProcess::pid() 用于标识进程。到目前为止,搜索 Qt 文档还没有找到有用的解决方案。
提前致谢!
示例
int main() {
QProcess* p = new QProcess(this);
p->start("C:\test.exe");
func(p);
return 0;
}
void func (QProcess* p)
{
qDebug() << "The application name of the app with pid" << p->pid() << "is" << p->name(); // name() doesn't exist, that's where I need help
}
尝试使用 QProcess 对象的 program()
方法,像这样:
QProcess process(this);
process.start("calc.exe");
qDebug() << process.program();
process.waitForFinished();