Solved

Mimicking Windows Task Manager

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

Suggested Solutions

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

735 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