标签:word 判断 getc 管理者 process sizeof handle runas info
#include <windows.h>
//调用GetTokenInformation函数,获取TOKEN_ELEVATION结构体信息,通过结构体中的TokenIsElevated字段就能判断出来
bool IsRunasAdmin()
{
bool bElevated = false;
HANDLE hToken = NULL;
// Get current process token
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
return FALSE;
TOKEN_ELEVATION tokenEle;
DWORD dwRetLen = 0;
// Retrieve token elevation information
if (GetTokenInformation(hToken, TokenElevation, &tokenEle, sizeof(tokenEle), &dwRetLen))
{
if (dwRetLen == sizeof(tokenEle))
{
bElevated = tokenEle.TokenIsElevated;
}
}
CloseHandle(hToken);
return bElevated;
}
标签:word 判断 getc 管理者 process sizeof handle runas info
原文地址:https://www.cnblogs.com/lizhanzhe/p/10951867.html