few days ago i asked about how to get all running processes in the system using QProcess.
i found a command line that can output all processes to a file:
C:WINDOWSsystem32wbemwmic.exe" /OUTPUT:C:ProcessList.txt PROCESS get Caption
this will create C:ProcessList.txt file contains all running processes in the system.
i wonder how can i run it using QProcess and take its output to a variable.
it seems every time i try to run it and read nothing happens:
QString program = "C:\WINDOWS\system32\wbem\wmic.exe";
QStringList arguments;
arguments << "/OUTPUT:C:\ProcessList.txt" <<"PROCESS"<< "get"<< "Caption";
process->setStandardOutputFile("process.txt");
process->start(program,arguments);
QByteArray result = process->readAll();
i prefer not to create process.txt at all and to take all the output to a variable...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…