Solved

Mimicking Windows Task Manager

Posted on 2004-04-18
4
731 Views
Last Modified: 2013-12-03
I'm trying to write an app to mimick the Windows Task Manager Processes tab. I can get a list of all the running processes using this code:

procedure TForm1.Button1Click(Sender: TObject);
var
 I: Integer;
 Snapshot: THandle;
 PE: TProcessEntry32;
begin
 ListBox1.Clear;
 Snapshot := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
 if (Snapshot = DWORD(-1)) then
     Exit;
 PE.dwSize := SizeOf(TProcessEntry32);
 if Process32First(Snapshot, PE) then
 repeat
   I := ListBox1.Items.Add(PE.szExeFile);
 until not Process32Next(Snapshot, PE);
 CloseHandle (Snapshot);
end;

Which works great, but I'd like to show other stuff like the CPU usage used, RAM used etc by each process. The app needs to run under Win2000/XP/2003 (ie. not 9X).

I think this information might be obtainable via WMI but it needs to be fast (WMI seems to be a little slow/CPU-intensive) so another method would be preferable :)
0
Comment
Question by:nem2k4
  • 2
4 Comments
 
LVL 3

Expert Comment

by:MikProg
ID: 10856751
Key words "Performance Objects and Counters" in Win32 Developer's reference (Windows SDK in Delphi menu). But it is not so easy as process listing.
0
 

Author Comment

by:nem2k4
ID: 10856811
Damn I was hoping you wouldn't say that :( :D
0
 
LVL 3

Expert Comment

by:MikProg
ID: 10857033
Don't worry! Seek Internet. Some days ago I read piece of source that realise counter readng. If I would know you need it. It was one of the poplular Delphi sites but I can't remeber name (today I can't remember my name. Ooh! These weekend's)
0
 
LVL 7

Accepted Solution

by:
sftweng earned 75 total points
ID: 10857274
Perhaps you could use the Performance Data Helper (pdh.h) - see http://swiss.torry.net/classes.htm
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now