函数参考


_Security__GetTokenInformation

检索访问令牌信息指定的类型

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

参数

$hToken 资料检索的访问令牌句柄.
如果 $iClass 指定为 $sTokenSource, 句柄必须 $TOKEN_QUERY_SOURCE 访问.
对于所有其他 $iCLASS 值,句柄必须有 $TOKEN_QUERY 访问.
$iClass 指定一个值, 以标识函数检索信息的类型

返回值

成功: 返回所要求资料的字节结构
失败: 返回 0

注意/说明

None.

相关

_Security__OpenProcessToken, _Security__OpenThreadToken, _Security__OpenThreadTokenEx

详情参考

在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