본문 바로가기
C++

GetCurrentProcess function

by leo21c 2014. 3. 4.
SMALL

출처: http://msdn.microsoft.com/en-us/library/windows/desktop/ms683179(v=vs.85).aspx
 GetCurrentProcess function

Retrieves a pseudo handle for the current process.

Syntax

HANDLE WINAPI GetCurrentProcess(void);

Parameters

This function has no parameters.

Return value

The return value is a pseudo handle to the current process.

Remarks

A pseudo handle is a special constant, currently (HANDLE)-1, that is interpreted as the current process handle. For compatibility with future operating systems, it is best to call GetCurrentProcess instead of hard-coding this constant value. The calling process can use a pseudo handle to specify its own process whenever a process handle is required. Pseudo handles are not inherited by child processes.

This handle has the PROCESS_ALL_ACCESS access right to the process object. For more information, seeProcess Security and Access Rights.

Windows Server 2003 and Windows XP:  This handle has the maximum access allowed by the security descriptor of the process to the primary token of the process.

A process can create a "real" handle to itself that is valid in the context of other processes, or that can be inherited by other processes, by specifying the pseudo handle as the source handle in a call to theDuplicateHandle function. A process can also use the OpenProcess function to open a real handle to itself.

The pseudo handle need not be closed when it is no longer needed. Calling the CloseHandle function with a pseudo handle has no effect. If the pseudo handle is duplicated by DuplicateHandle, the duplicate handle must be closed.

Windows Phone 8: This API is supported.

Examples

For an example, see Creating a Child Process with Redirected Input and Output.

Requirements

Minimum supported client

Windows XP [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2003 [desktop apps | Windows Store apps]

Header

WinBase.h on Windows XP, Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008, and Windows Server 2008 R2 (include Windows.h);
Processthreadsapi.h on Windows 8 and Windows Server 2012

Library

Kernel32.lib

DLL

Kernel32.dll

See also

CloseHandle
DuplicateHandle
GetCurrentProcessId
GetCurrentThread
OpenProcess
Process and Thread Functions
Processes


LIST