QProcess 启动win第三方程序
来源:互联网 发布:安卓内核优化修改 编辑:程序博客网 时间:2024/06/04 00:51
我不知道哪里错了
prog = new QProcess(this);
QString fullpath = QString("%1/%2").arg(QCoreApplication::applicationDirPath()).arg(exeName);
qDebug() << "launch full path =" << fullpath << ", argv =" << argv;
prog->setObjectName(fullpath);
connect(prog, SIGNAL(finished(int,QProcess::ExitStatus)),
this, SLOT(finishedSlot(int,QProcess::ExitStatus)));
prog->start(fullpath, argv);如果这样写就启动不起来。
下面写的就可以
m_pOtherProcess = new QProcess(this); QString t_otherExePath = QString("%1/%2").arg(QCoreApplication::applicationDirPath()).arg(otherExeName); QString t_otherExeDirPath = QString("%1").arg(QCoreApplication::applicationDirPath()); if(!QFile::exists(t_otherExePath)) { qDebug()<<"robin:otherExe not exist"; return -1; } connect(m_pOtherProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(finishedSlot(int,QProcess::ExitStatus))); m_pOtherProcess->setObjectName(t_otherExePath); m_pOtherProcess->setWorkingDirectory(t_otherExeDirPath); m_pOtherProcess->setProgram(t_otherExePath); m_pOtherProcess->start();
我不想找原因了,我要忙别的了。其实上面的代码之前也是可以的,但是不知道为什么不行了
下面是终极办法,肯定可以。
bool runWinExe(const QString &path)
{
Q_ASSERT(QFile::exists(path));
bool run = false;
#if defined(Q_OS_WIN)
SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
sei.lpVerb = TEXT("runas");
WCHAR wfile[256];
memset(wfile, 0, sizeof(wfile));
path.toWCharArray(wfile);
sei.lpFile = wfile;//add application which you want to run as administrator here
sei.nShow = SW_SHOWNORMAL;//without this,the windows will be hiden
run = ShellExecuteEx(&sei);
#else
run = QProcess::startDetached(path);
#endif
return run;
}
0 0
- QProcess 启动win第三方程序
- QProcess类启动第三方应用
- symbian 安装启动第三方程序
- android 启动第三方程序的代码
- Android中如何启动第三方程序?
- Android中如何启动第三方程序
- 【运维】服务器自动启动第三方程序
- android 启动第三方程序的代码
- Android Intent 启动第三方程序
- [Howto]在Symbian程序中启动第三方程序
- android启动第三方程序的代码(利用ComponentName)
- android 启动第三方程序的代码(利用ComponentName)
- android 启动第三方程序的代码(利用ComponentName)
- android 已有apk 启动第三方程序
- linux下python启动第三方程序,并控制关闭
- Android中启动第三方程序的代码
- Qt Qprocess 启动新程序切换工作目录
- Android apk签名、第三方内置、图标添加与删除、开关机动画及铃声、启动第三方程序
- poj Heavy Transportation(dijkstra,spfa)
- myeclipse 配置struts出现 Unable to load configuration.
- hdu 3987 Harry Potter and the Forbidden Forest (最小割)
- Docker 总结
- 自定义控件—自定义的ExpandableTextView
- QProcess 启动win第三方程序
- ROS入门_1.18 接下来做什么?
- CSS3之转换 、过渡 、动画
- 设计模式初体验之单例模式
- HTML基础语法,结构!
- AVL Tree(1)
- Android中rxjava2的基本使用
- 2016年的自我反省
- java中的参数传递方式