August 19, 2012

qtdev qtdev
Lab Rat
16 posts

Get Application Name ..

 

  1. #include <QtCore/QCoreApplication>
  2. #include <QProcess>
  3. #include <QDebug>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7.     QCoreApplication a(argc, argv);
  8.  
  9.     QProcess process;
  10.     process.setReadChannel(QProcess::StandardOutput);
  11.     process.setReadChannelMode(QProcess::MergedChannels);
  12. //    process.start("cmd.exe /C echo test");
  13.     process.start("wmic.exe /OUTPUT:STDOUT PROCESS get Caption");
  14.  
  15.     process.waitForStarted(1000);
  16.     process.waitForFinished(1000);
  17.  
  18.     QByteArray list = process.readAll();
  19.     qDebug() << "Read" << list.length() << "bytes";
  20.     qDebug() << list;
  21. }

I use this program to list out all process which are running.. but i want to get application names which started by user and they are at running state..like vlc media player,ms word etc. ..

Thanks in advance..

Gerolf: Added code tags

1 reply

August 19, 2012

koahnig koahnig
Mad Scientist
2199 posts

Please use code wrappings as explained here [qt-project.org] This makes your code readable.

 
  ‹‹ [SOLVED] Require help on Dragging a Row From QTableview and drop into a sub-classed PushButton      How to open a directory and check this content? ››

You must log in to post a reply. Not a member yet? Register here!