语言

Process.TryGetProcessById(Int32, Process) 方法

定义

尝试获取 Process 具有指定进程 ID 的现有进程的实例。

public:
 static bool TryGetProcessById(int processId, [Runtime::InteropServices::Out] System::Diagnostics::Process ^ % process);
[System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static bool TryGetProcessById(int processId, out System.Diagnostics.Process? process);
[<System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member TryGetProcessById : int * Process -> bool
Public Shared Function TryGetProcessById (processId As Integer, ByRef process As Process) As Boolean

参数

processId
Int32

要查找的进程的进程 ID。

process
Process

此方法返回 true时,包含一个 Process 表示现有进程;否则为 null。

返回

true 如果找到了进程,则为 ;否则,为 false.

属性

例外

processId 小于或等于零。

适用于