Function Reference


Returns the access token associated with a process

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


$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.


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



See Also

Search OpenProcessToken in MSDN Library.


#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