C++ scanning process ids using the command prompt with tasklist

2.3k views Asked by At

I'm trying to use c++ to scan in the processes shown in the command prompt of windows when you type in tasklist. I haven't have the whole code ready but would like help in trying to read in the processes.

2

There are 2 answers

0
ultifinitus On

Well you can redirect the standard output, orrrr you can use winapi =)

List of functions to do with processes: http://msdn2.microsoft.com/en-us/library/ms684847.aspx

EnumProcesses function: http://msdn.microsoft.com/en-us/library/ms682629.aspx

0
Collin Dauphinee On

You'll need to use PSAPI to do this. You may need to add psapi.lib to your library dependencies.

You can use EnumProcesses to fill an array with the IDs of all running processes. You can then use OpenProcess with the IDs in your array to retrieve a handle to each running process, then pass the handle to the relevant functions, such as QueryWorkingSet to get information about each process.

You can most likely find examples on the MSDN, if you need more help.