Home > Language Reference > System Functions > GetProcessList

GetProcessList

The GetProcessList function returns the list of active processes and their attributes.

Syntax

ret = GetProcessList(<tab_process>, <tab_PID>, <tab_cpu>, <tab_mem>, 0|1|2|3|4)

Parameters

<tab_process>, array of strings, contains the list of active processes.

<tab_PID>, array of integers, contains the PID of the active processes.

<tab_cpu>, array of integers, contains the total processor time (in seconds) for each active process.

<tab_mem>, array of integers, contains the memory usage (in Kbytes) for each active process.

0|1|2|3|4, integer. The possible values for this sorting parameter are:
 Value  Description
 0  retrieved data not sorted
 1  retrieved data sorted by process name
 2  retrieved data sorted by PID
 3  retrieved data sorted by CPU usage (from the highest to the lowest)
 4      retrieved data sorted by memory usage (from the highest to the lowest)

Return value

ret, integer. If the function succeeds, the return value is the number of processes found. If the function fails, the return value is a negative nonzero value (see System Functions Error Codes).

See also

GetWindowsList

Example

dim name$(210)
dim pid(210)
dim cputime(210)
dim memuse(210)
'Create a txt file which receives the GetProcessList results
proc$="c:\wttest\process.txt"
create(proc$)

p=GetProcessList(name$(),pid(),cputime(),memuse(),1)
'Write in the first record of process.txt file the number of processes
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$)