Autor Beitrag
chukalv
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44



BeitragVerfasst: So 21.05.06 18:25 
Is there aposibilliaty to get the windows task list WITH the memory usage of every task? Maybe any components? Found some scripts, but there are eithe usings dll`s or just showing the tasks without the memory usage...

Thanks!
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Mo 22.05.06 09:13 
Im not a WinAPI freak but the procedure is that you have to enumerate all processes and to get further informations by using the determined PIDs. Processexplorer from sysinternals.com is OSS so you might have a look at it. But i guess that there's better delphi code but for english this might be the wrong place ;-)
chukalv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44



BeitragVerfasst: Mo 22.05.06 14:10 
Will have a look to the Processexplorer at home (at my job it doesn`t likes the name, because of a stupid proxy filter - Processexplorer :x )

How to get the PID`s from the current running processes I know. But I can`t find ANY documentation how to get the memory usage from it..

P.S. Understand German is not a problem for me...Just with the writting.. :oops:
chukalv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44



BeitragVerfasst: Mo 22.05.06 19:07 
digi_c: Sorry. but didn`t found any source code of the Processes Explorer..

About this one code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
var
  pmc: PPROCESS_MEMORY_COUNTERS;
  cb: Integer;
begin
  cb := SizeOf(_PROCESS_MEMORY_COUNTERS);
  GetMem(pmc, cb);
  pmc^.cb := cb;
  if GetProcessMemoryInfo(GetCurrentProcess(), pmc, cb) then
    Label1.Caption := IntToStr(pmc^.WorkingSetSize) + ' Bytes'
  else
    Label1.Caption := 'Unable to retrieve memory usage structure';

  FreeMem(pmc);


It`s showing my projects memory usage, but how to change it so that it`s showing the memory of any given process from it`s process name or PID?
Didn`t found any other code examples...
0xCC
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 150



BeitragVerfasst: Mo 22.05.06 19:42 
user profile iconchukalv hat folgendes geschrieben:
digi_c: Sorry. but didn`t found any source code of the Processes Explorer..

About this one code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
var
  pmc: PPROCESS_MEMORY_COUNTERS;
  cb: Integer;
begin
  cb := SizeOf(_PROCESS_MEMORY_COUNTERS);
  GetMem(pmc, cb);
  pmc^.cb := cb;
  if GetProcessMemoryInfo(GetCurrentProcess(), pmc, cb) then
    Label1.Caption := IntToStr(pmc^.WorkingSetSize) + ' Bytes'
  else
    Label1.Caption := 'Unable to retrieve memory usage structure';

  FreeMem(pmc);


It`s showing my projects memory usage, but how to change it so that it`s showing the memory of any given process from it`s process name or PID?
Didn`t found any other code examples...


use openprocess instead of getcurrentprocess...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var prochnd: thandle
procHnd :=  OpenProcess( PROCESS_QUERY_INFORMATION,false,ProcessID);
GetProcessMemoryInfo(prochnd, pmc, cb)...

CloseHandle(prochnd);