Process.Handle Property

Definition

Gets the native handle of the associated process.

C#
public IntPtr Handle { get; }
C#
[System.ComponentModel.Browsable(false)]
public IntPtr Handle { get; }

Property Value

IntPtr

The handle that the operating system assigned to the associated process when the process was started. The system uses this handle to keep track of process attributes.

Attributes

Exceptions

The process has not been started or has exited. The Handle property cannot be read because there is no process associated with this Process instance.

-or-

The Process instance has been attached to a running process but you do not have the necessary permissions to get a handle with full access rights.

You are trying to access the Handle property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.

Remarks

An application can obtain a handle to a process that can be used as a parameter to many process-information and control functions. You can use this handle to initialize a WaitHandle or to call native methods with platform invoke.

This process handle is private to an application--in other words, process handles cannot be shared. A process also has a process Id which, unlike the Handle, is unique and, therefore, valid throughout the system.

Only processes started through a call to Start set the Handle property of the corresponding Process instances.

Applies to

Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

See also