检查进程用户是否是管理员 C++ [英] Check if process user is an administrator c++

查看:84
本文介绍了检查进程用户是否是管理员 C++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取进程的用户名并检查它是否是本地管理员.或者直接查看当前procees用户是否是本地管理员

I want to get the process's user name and check if it is a local administrator . Or check directly if the current procees user is a local administrator

推荐答案

使用 GetUserName() 获取当前用户名,然后调用 NetUserGetInfo() 以及您刚刚获得的服务器名称(本地为 NULL)和用户名.传递一个 USER_INFO_1 结构,然后访问结构中的 usri1_priv.如果值为 USER_PRIV_ADMIN,那么您就会知道用户名是管理员.

Get the current username with GetUserName(), then call NetUserGetInfo() with the server name (NULL for local) and username you just got. Pass it a USER_INFO_1 structure, and then access usri1_priv in the structure. If the value is USER_PRIV_ADMIN, then you'll know that the username is an admin.

这篇关于检查进程用户是否是管理员 C++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆