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, String)

Returns a new Process component given a process identifier and the name of a computer in the network.

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

Parameters

processId
The system-unique identifier of a process resource.
machineName
[To be supplied.]

Return Value

A Process component associated with a remote 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 a remote computer on the network. The process resource must already exist on the specified 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.

If you do not specify a machineName, the local computer is used. You can alternately specify the local computer by setting machineName to the value "." or an empty string ("").

See Also

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