NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Process.GetProcessById (Int32)

Returns a new Process component given the identifier of a process on the local computer.

[Visual Basic]
Overloads Public Shared Function GetProcessById( _
   ByVal processId As Integer _
) As Process
[C#]
public static Process GetProcessById(
   int processId
);
[C++]
public: static Process* GetProcessById(
   int processId
);
[JScript]
public static function GetProcessById(
   processId : int
) : Process;

Parameters

processId
The system-unique identifier of a process resource.

Return Value

A Process component associated with a local process resource identified by the given Id.

Remarks

Use this method to create a new Process component and associate it with a process resource on the local computer. The process resource must already exist on the computer, because GetProcessById does not create backend resources, but rather associates them with an application-generated Process component. A process Id can only be retrieved for a process that is currently running on the computer. Once the process terminates, GetProcessById throws an exception if you pass in an expired Id.

On any given computer, the Id of a process is unique. GetProcessById returns one process at most. If you want to get all processes running a particular application, use GetProcessesByName. If there are multiple processes on the given computer running the application specified by the processName

parameter, GetProcessesByName returns an array containing all associated processes. You can query each of these processes in turn for their Id. The process ID can be viewed in the Windows Task Manager's Processes panel. The PID column gives the process ID assigned to a process.

Because the GetProcessById method is static (in Visual Basic Shared), you do not need to create an instance of the Process component before you call the method. You can call the method on the Process class itself.

See Also

Process Class | Process Members | System.Diagnostics Namespace | Process.GetProcessById Overload List | Id | GetProcessesByName | GetProcesses | GetCurrentProcess