如何枚举另一个用户会话的打开窗口(~EnumWindows) [英] How can I enumerate the open windows (~EnumWindows) of another user session

查看:28
本文介绍了如何枚举另一个用户会话的打开窗口(~EnumWindows)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序可以列出当前会话的打开窗口.它使用来自 user32.dll 的 EnumWindows 方法.

I have an application that can list the opened windows of the current session. It uses the EnumWindows method from the user32.dll.

我想从 Windows 服务运行此代码,但由于该服务未附加到用户会话,因此显然什么都不返回.

I would like to run this code from a windows service, but as the service is not attached to a user session, it returns nothing obviously.

所以问题是,我如何枚举另一个用户会话(例如,具有特定登录用户)的打开窗口?

So the question is, how can I enumerate the open windows of another user session (e.g. with a specific logon user)?

与 EnumWindows 类似,我也想获取用户会话的前台窗口(例如 GetForegroundWindow 适用于当前用户).

Similarly to EnumWindows, I also would like to get the foreground window of the user session as well (like GetForegroundWindow works for the current user).

推荐答案

据我所知,您无法从另一个会话访问一个会话的窗口.还值得注意的是,实际上并没有当前会话"之类的东西——可能有多个用户通过终端服务登录,或者 XP 的快速用户切换.

As far as I'm aware, you can't access the windows of one session from another. It's also worth noting that there's not really any such thing as "the current session" - there may be multiple users logged on through terminal services, or XP's fast user switching.

对此的一种方法是将程序添加到每个用户的个人资料中,而没有仅与您的服务进行通信的 UI.不过,您仍然必须应对可能存在多个活动会话的事实.

One approach to this would be to add a program to each user's profile with no UI that just communicates with your service. You'd still have to cope with the fact that there could be multiple active sessions, though.

这篇关于如何枚举另一个用户会话的打开窗口(~EnumWindows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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