Core Function ProcessList

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> ProcessList( <name> ) </pre> === Description === Returns an array listing the currently running processes (names and PIDs) === Parameters === ==== name ==== Optional;...")
 
(Example)
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]]

Revision as of 04:07, 23 November 2011

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;
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox