Solved

Mimicking Windows Task Manager

Posted on 2004-04-18
4
735 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Process Javascript errors with Delphi TWebBrowser 1 113
Delphi selector screen 2 70
How to debug For loops? 3 46
Convert a string into a TDateTime 5 52
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

24 Experts available now in Live!

Get 1:1 Help Now