bool isRunningAsAdmin()
{
BOOL runningAsAdmin = false;
PSID adminGroupSid = NULL; // allocate and initialize a SID of the administrators group.
SID_IDENTIFIER_AUTHORITY NtAuthority = { SECURITY_NT_AUTHORITY };
if (AllocateAndInitializeSid(
&NtAuthority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&adminGroupSid))
{
// determine whether the SID of administrators group is enabled in
// the primary access token of the process.
CheckTokenMembership(NULL, adminGroupSid, &runningAsAdmin);
} if (adminGroupSid)
{
FreeSid(adminGroupSid);
} return runningAsAdmin;
}Qt 判断以管理员身份运行
原创文章标签 RunningAsAdmin 管理员身份 文章分类 JavaScript 前端开发
上一篇:Qt 读写windows注册表
-
以管理员身份运行IJjava spring 其他
-
cmd以管理员身份运行
cmd以管理员身份运行
windows 拒绝访问 右键 cmd命令
















