Copy code
QProcess p(0);
p.start("route");
p.waitForStarted();
p.waitForFinished();
qDebug()<<QString::fromLocal8Bit(p.readAllStandardError());
Copy code
QProcess p(0);
p.start("ipconfig");
p.waitForStarted();
p.waitForFinished();
qDebug()<<QString::fromLocal8Bit(p.readAllStandardOutput());
而 dir 是命令行提供的命令,不是程序!
Copy code
QProcess p(0);
p.start("cmd");
p.waitForStarted();
p.write("dir\n");
p.closeWriteChannel();
p.waitForFinished();
qDebug()<<QString::fromLocal8Bit(p.readAllStandardOutput());
或
Copy code
QProcess p(0);
p.start("cmd", QStringList()<<"/c"<<"dir");
p.waitForStarted();
p.waitForFinished();qDebug()<<QString::fromLocal8Bit(p.readAllStandardOutput());