Core Function ProcessList
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> ProcessList( <name> ) </pre> === Description === Returns an array listing the currently running processes (names and PIDs) === Parameters === ==== name ==== Optional;...") |
m (1 revision) |
||
(2 intermediate revisions by one user not shown) | |||
Line 45: | Line 45: | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
+ | println( "Notepad PID : " . FindPID("Notepad.exe") ); | ||
+ | |||
+ | Function FindPID( $Name ) | ||
+ | { | ||
+ | foreach ( ProcessList($Name) as $pList ) | ||
+ | return $pList[1]; | ||
+ | return -1; | ||
+ | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Latest revision as of 12:38, 14 June 2015
ProcessList( <name> )
Contents |
Description
Returns an array listing the currently running processes (names and PIDs)
Parameters
name
Optional; If a name is given only processes of the same name will be returned.
Return Value
Success: An array of process names and PIDs (See Example). Failure: An empty array.
Remarks
None.
Example
Print all process names and pids :
foreach ( ProcessList() as $pList ) { println("Name '$pList[0]' PID '$pList[1]'"); }
Print just the notepad process name and pid :
foreach ( ProcessList("Notepad.exe") as $pList ) { println("Name '$pList[0]' PID '$pList[1]'"); }
A simple function to accept a process name and return its pid or return -1 :
println( "Notepad PID : " . FindPID("Notepad.exe") ); Function FindPID( $Name ) { foreach ( ProcessList($Name) as $pList ) return $pList[1]; return -1; }