Expand Minimize

OpenProcessToken function

The OpenProcessToken function opens the access token associated with a process.

Syntax


BOOL WINAPI OpenProcessToken(
  _In_   HANDLE ProcessHandle,
  _In_   DWORD DesiredAccess,
  _Out_  PHANDLE TokenHandle
);

Parameters

ProcessHandle [in]

A handle to the process whose access token is opened. The process must have the PROCESS_QUERY_INFORMATION access permission.

DesiredAccess [in]

Specifies an access mask that specifies the requested types of access to the access token. These requested access types are compared with the discretionary access control list (DACL) of the token to determine which accesses are granted or denied.

For a list of access rights for access tokens, see Access Rights for Access-Token Objects.

TokenHandle [out]

A pointer to a handle that identifies the newly opened access token when the function returns.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

Close the access token handle returned through the TokenHandle parameter by calling CloseHandle.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Winbase.h (include Windows.h)

Library

Advapi32.lib

DLL

Advapi32.dll

See also

Access Control
Basic Access Control Functions
AccessCheck
AdjustTokenGroups
AdjustTokenPrivileges
CloseHandle
GetTokenInformation
OpenThreadToken
SetTokenInformation

 

 

Community Additions

ADD
Show:
© 2014 Microsoft