通过 win32 检测多个登录用户 [英] Detecting multiple logged on users via win32

查看:17
本文介绍了通过 win32 检测多个登录用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用标准的 win32 api,检测多个用户登录的最佳方法是什么?我有一个升级到我们的软件产品,当多个用户登录时,它无法运行.(我知道这是一件应该避免的事情,因为它的烦恼因素,但该产品非常复杂.您必须当我说真的没有其他解决方案时请相信我.)谢谢.

Using the standard win32 api, what's the best way to detect more than one user is logged on? I have an upgrade to our software product that can't be run when more than one user is logged in. (I know this is something to be avoided because of its annoyance factor, but the product is very complicated. You'll have to trust me when I say there really is no other solution.) Thanks.

推荐答案

为了让多个用户同时登录,必须启用终端服务或快速用户切换.由于快速用户切换是使用终端服务实现的,您首先需要确定操作系统是否启用了它.您可以将 GetVersionExOSVERSIONINFOEX.检查 VER_SUITE_SINGLEUSERTS 和 VER_SUITE_TERMINAL 标志.

In order to have more than one user logged in at once, Terminal Services or Fast User Switching must be enabled. Since Fast User Switching is implemented using Terminal Services, you first need to find out if the OS has it enabled. You can use GetVersionEx with an OSVERSIONINFOEX. Check for the VER_SUITE_SINGLEUSERTS and VER_SUITE_TERMINAL flags.

如果启用了 TS,您可以使用 WTSEnumerateSessions 来查找有多少用户登录.这仅在终端服务"服务启动时有效.

If TS is enabled, you can use WTSEnumerateSessions to find out how many users are logged on. This only works if the "Terminal Services" service is started.

如果机器不支持终端服务(或者服务没有启动),那么你只能让一个用户登录.

If the machine doesn't support Terminal Services (or if the service isn't started), then you can only have one user logged on.

这篇关于通过 win32 检测多个登录用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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