如何获取 Windows 在登录屏幕上显示的用户帐户列表? [英] How can I get the list of user accounts that Windows presents on the Log-On screen?

查看:34
本文介绍了如何获取 Windows 在登录屏幕上显示的用户帐户列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 NetQueryDisplayInformation(我已经尝试过 NetUserEnum 函数)来获取本地计算机上的一组用户帐户.我可以通过这种方式获取所有帐户 - 但我只想要与实际人类相关联的帐户,而不是例如用于软件更新的隐藏帐户.

I'm using NetQueryDisplayInformation (I've already tried the NetUserEnum function) to get the set of user accounts on the local machine. I can get all the accounts this way - but I only want the accounts associated with actual human beings, and not, for example, hidden accounts used for software updates.

阅读之后MSDN 文档有关相关结构和类似的堆栈问题,我看不到任何东西可以让我过滤到我需要的帐户.

After reading the MSDN documentation on the relevant structures and similar Stack questions, I see nothing that can allow me to filter to just the accounts that I need.

理想情况下,有人会有一个简单可靠的解决方案:

Ideally, someone will have a simple and reliable solution that:

  1. 不涉及使用未记录的注册表项
  2. 不依赖于枚举磁盘上的用户文件夹
  3. 我不会尝试建立一个详尽的非真实用户帐户列表
  4. 出于技术原因,WMI 不是一种选择

有什么想法吗?

[很久以后]得到了答案,但不是在这里 - 只需枚举每个用户的组.真人"帐户将是管理员、高级用户、用户、访客中的一个或多个的成员.

[Much later] Got the answer, but not here - just enumerate the groups for each user. "Real human" accounts will be a member of one or more of Administrator, Power User, User, Guest.

推荐答案

您可以使用 NetQueryDisplayInformation API,结合按位检查用户信息标志.

You can use NetQueryDisplayInformation API, combine with bitwise check on user info flag.

我有完全相同的要求,所以我编写了示例代码(从 MSDN GROUP 查询修改).

I have exactly the same requirements, so I cook sample code (modified from MSDN GROUP query).

我使用的用户标志是:

UF_NORMAL_ACCOUNT
UF_ACCOUNTDISABLE
UF_PASSWD_NOTREQD ---> this ensure we get Human account, Human account always requires password.

工作代码位于:http://www.cceye.com/list-system-normal-user-account-only/

这篇关于如何获取 Windows 在登录屏幕上显示的用户帐户列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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