GetCurrentProcess

Syntax

HANDLE GetCurrentProcess();

A handle to the process is returned. This handle is implicitly created for the calling process. The handle is valid and has full access rights to the process. It does not need to be closed.

Parameters

This function does not take any parameters.

Return Value

The return value is a handle to the current process. This handle is special and can be used by any process that runs on the same machine. The handle is valid and has full access rights to the process. This handle is not a process identifier (PID). To get the PID, use the GetCurrentProcessId function.

Remarks

The handle returned by GetCurrentProcess is a pseudohandle. This pseudohandle is equivalent to a handle to the current process. The pseudohandle is valid for use by any process on the same machine. The system automatically duplicates the pseudohandle to the calling process.

The pseudohandle is automatically closed when the calling process terminates. You do not need to call the CloseHandle function for this handle.

The GetCurrentProcess function is useful for specifying the current process in any Win32 API function that requires a process handle.

Example

The following example retrieves a handle to the current process and then closes it. This is done to demonstrate that the handle is a real handle that can be manipulated, even though it's a pseudohandle.

See Also