List running processes

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 4
Reputation: Zach1188 is an unknown quantity at this point 
Solved Threads: 0
Zach1188 Zach1188 is offline Offline
Newbie Poster

List running processes

 
0
  #1
Sep 14th, 2008
I am trying to write a program, for practice, similar to the task manager, that lists running process, and their path if possible. I have spent hours all over Google and I can't find anything. Ideally, it would be nice to put the processes and their paths into an array, in this format:

  1. list[0] = "C:\Game.exe";
  2. list[1] = "C:\MusicPlayer.exe";
  3. list[2] = "C:\Calculator.exe";

Any ideas?
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,953
Reputation: Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of 
Solved Threads: 214
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: List running processes

 
0
  #2
Sep 14th, 2008
Use CreateToolhelp32Snapshot() with the TH32CS_SNAPPROCESS flag and Process32First() and Process32Next() to get a list of processes on the system.

For each process, create another snapshot using the TH32CS_SNAPMODULE flag and the process ID. For each module ID use GetModuleFileName(), and look for the modules whose names end in ".exe".
The MSDN toolhelp documetation gives examples like how to traverese the module list.

Don't forget to use CloseHandle() on each snapshot when you are done with it.

Hope this helps.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC