↑  ←  Описание функции


_Security__GetTokenInformation

Retrieves a specified type of information about an access token

#include <Security.au3>
_Security__GetTokenInformation($hToken, $iClass)

Параметры

$hToken A handle to an access token from which information is retrieved. If $iClass specifies
    $sTokenSource, the handle must have $TOKEN_QUERY_SOURCE access. For all other $iClass values, the handle must
    have $TOKEN_QUERY access.
$iClass Specifies a value to identify the type of information the function retrieves

Возвращаемое значение

Успех:A byte structure filled with the requested information
Ошибка:Возвращает 0

См. также

_Security__OpenProcessToken, _Security__OpenThreadToken, _Security__OpenThreadTokenEx

См. также

Искать GetTokenInformation в библиотеке MSDN

Пример

#include <SecurityConstants.au3>
#include <Security.au3>
#include <WinAPI.au3>

Example_TokInfo()

Func Example_TokInfo()
    Local $hProcess = _WinAPI_GetCurrentProcess()
    If @error Then Return ; check for possible errors

    Local $hToken = _Security__OpenProcessToken($hProcess, $TOKEN_ALL_ACCESS)
    ; If token is get...
    If $hToken Then
        ; Get information about the type of this token:
        Local $tInfo = _Security__GetTokenInformation($hToken, $TOKENTYPE)
        ; The result will be raw binary data. For $TOKENTYPE it's TOKEN_TYPE value (enum value). Reinterpreting as "int" type therefore:
        Local $iTokenType = DllStructGetData(DllStructCreate("int", DllStructGetPtr($tInfo)), 1)

        ConsoleWrite("Token type is " & $iTokenType & @CRLF) ; Can be value of either $TOKENPRIMARY or $TOKENIMPERSONATION

        ; Close the token handle
        _WinAPI_CloseHandle($hToken)
    EndIf
EndFunc   ;==>Example_TokInfo