954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

List running processes

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:

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


Any ideas?

Zach1188
Newbie Poster
4 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

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.

Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You