GetCurrentProcess
HANDLE GetCurrentProcess(void);
Description
The GetCurrentProcess function returns a pseudo handle for the current process.
A pseudo handle is a special constant that is equivalent to the actual handle of the current process.
The pseudo handle is valid only within the calling process and can be used by any function that requires a process handle, such as process security and information functions.
This function simplifies the process of obtaining a handle to the current process. For example, you can use it to specify the current process when calling the DuplicateHandle function to create a duplicate handle to the current process.
Return Value
The return value is a pseudo handle for the current process.
Remarks
The pseudo handle returned by GetCurrentProcess is equivalent to the handle returned by OpenProcess when called with the process identifier of the current process.
Pseudo handles are a convenience. You can typically use them interchangeably with real handles obtained from OpenProcess. However, some functions may require a real handle. In such cases, you should explicitly open a handle to the current process using OpenProcess with the correct access rights.
The pseudo handle can be closed using CloseHandle. Closing the pseudo handle has no effect on the process. However, it is good practice to close any handle that is no longer needed.
Requirements
| Component | Value |
|---|---|
| Minimum supported client | Windows XP [desktop apps only] |
| Minimum supported server | Windows Server 2003 [desktop apps only] |
| Target Platform | Windows |
| Header | processthreadsapi.h |
| Library | Kernel32.lib |
| DLL | Kernel32.dll |