Description
The GetProcessList
function returns the list of active processes and their attributes. Not available in WinTask Lite.
Syntax
GetProcessList(<tab_name$>, <tab_PID>, <tab_CPU>, <tab_Mem>, <sort>)
or
Ret = GetProcessList(<tab_name$>, <tab_PID>, <tab_CPU>, <tab_Mem>, <sort>)
Parameters
<tab_name$>
: alphanumeric array, list of the active processes and attributes (the list displayed by the Process Tab of Task manager).<tab_PID>
: integer array, list of the PIDs for each process.<tab_CPU>
: integer array; contains the cumulative CPU used (in seconds) by each individual active process.<tab_Mem>
: integer array; contains the memory (in Kbytes) used by each individual process.<sort>
: integer which indicates how the result array should be sorted:- 0: result array not sorted
- 1: result array sorted by process name
- 2: result array sorted by PID
- 3: result array sorted by CPU usage (from the highest to the lowest)
- 4: result array sorted by memory usage (from the highest to the lowest)
Return Value
Ret
, integer, return code which gives the number of processes found. If any of the arrays is too small, ret contains -1, but the arrays will still contain the first n processes found (if #IgnoreErrors=1
). If Ret=-1
and if #IgnoreErrors=0
, the script is stopped.
Example Code
dim name$(210)
dim pid(210)
dim cputime(210)
dim memuse(210)
proc$="process.txt"
create(proc$)
p = GetProcessList(name$(), pid(), cputime(), memuse(), 1)
write(proc$, str$(p), CRLF)
i = 0
repeat
'The list is written to the file
write(proc$, name$(i) + "," + str$(pid(i)) + "," + str$(cputime(i)) + "," + str$(memuse(i)), CRLF)
i = i + 1
until i = p
pause 1
'The list is displayed
shell("notepad " + proc$)