Solved

Mimicking Windows Task Manager

Posted on 2004-04-18
4
743 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

738 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