Qt进阶-QProcess进程类打开Windows系统工具
添加头文件
# include <QProcess>
在按钮的槽函数中使用Qprocess的函数start()实现:
QProcess * poc = new QProcess;
poc-> start ( "C:\\Windows\\system32\\calc.exe" ) ;
QProcess * poc = new QProcess;
poc-> start ( "C:\\Windows\\system32\\mspaint.exe" ) ;
QProcess * poc = new QProcess;
poc-> start ( "C:\\Windows\\system32\\notepad.exe" ) ;
QProcess * poc = new QProcess;
poc-> start ( "C:\\Windows\\system32\\osk.exe" ) ;
QProcess * poc = new QProcess;
poc-> start ( "C:\\Windows\\system32\\charmap.exe" ) ;
QProcess * poc = new QProcess;
poc-> start ( "C:\\Windows\\system32\\write.exe" ) ;
QProcess * poc = new QProcess;
poc-> start ( "C:\\Windows\\system32\\taskmgr.exe" ) ;
QProcess * poc = new QProcess;
poc-> start ( "C:\\Windows\\system32\\winver.exe" ) ;
QProcess * poc = new QProcess;
poc-> start ( "C:\\Windows\\system32\\mstsc.exe" ) ;
QProcess * poc = new QProcess;
poc-> start ( "mmc devmgmt.msc" ) ;
在Win10可能会出现打不开屏幕键盘或设备管理器的情况,也可以使用以下方法:
system ( "start C:\\Windows\\System32\\devmgmt.msc" ) ;
system ( "start C:\\Windows\\System32\\osk.exe" ) ;
QProcess p ( 0 ) ;
p. start ( "cmd" , QStringList ( ) << "/c" << "ping www.baidu.com" ) ;
p. waitForStarted ( ) ;
p. waitForFinished ( ) ;
QString strTemp= QString :: fromLocal8Bit ( p. readAllStandardOutput ( ) ) ;
QMessageBox testMassage;
testMassage. setText ( strTemp) ;
testMassage. exec ( ) ;