Function Reference


_Security__OpenProcessToken

Returns the access token associated with a process

#include <Security.au3>
_Security__OpenProcessToken ( $hProcess, $iAccess )

Parameters

$hProcess A handle to the process whose access token is opened.
The process must have been given the $PROCESS_QUERY_INFORMATION access permission.
$iAccess Specifies an access mask that specifies the requested types of access to the access token.

Return Value

Success: an handle that identifies the newly opened access token when the function returns.
Failure: 0.

Remarks

Close the access token handle returned by calling _WinAPI_CloseHandle().

Related

_Security__OpenThreadToken

See Also

Search OpenProcessToken in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <Security.au3>
#include <SecurityConstants.au3>
#include <WinAPIHObj.au3>

Local $hToken = _Security__OpenProcessToken(_WinAPI_GetCurrentProcess(), $TOKEN_QUERY)
If $hToken Then
        ; $hToken is this process' token with $TOKEN_QUERY access

        ;... Do whatever with this token now and here...
        MsgBox($MB_SYSTEMMODAL, "OpenProcessToken", "$hToken = " & $hToken)

        ; Close handle when done
        _WinAPI_CloseHandle($hToken)
EndIf