简体   繁体   English

如何知道与流程关联的用户是否处于活动状态

[英]How to know if a user associated with a process is active

I use GetPixel to get colors of some points of Program Manager (desktop), however if the system is switched to another user, GetPixel always returns white . 我使用GetPixel获取Program Manager (桌面)某些点的颜色,但是,如果系统切换到另一个用户, GetPixel始终返回white

So I need to know whether the user is active or the system is switched to another user. 因此,我需要知道用户是处于活动状态还是系统已切换到另一个用户。

A solution should work for OS: Windows XP till Windows 8. 解决方案应适用于以下操作系统:Windows XP到Windows 8。

This is what I do: 这是我的工作:

HWND ProgmanHwnd = FindWindow(L"Progman", L"Program Manager");
if (!ProgmanHwnd) return;
HDC hDC = GetWindowDC(ProgmanHwnd);
if (!hDC) return;
COLORREF color = GetPixel(hDC, 10, 10); // it's always white when a used is logged off

Try to use WTSEnumerateSessionsEx . 尝试使用WTSEnumerateSessionsEx Returned structures have helpful fields State and pUserName . 返回的结构具有有用的字段StatepUserName

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM