954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Need help on developing apps with multiple users and active input desktop

Hi all, i'd like to ask anyone here who may help me solve this problem
i compiled an apps which records when is the last time user make an input, either with keyboard or moving mouse, thru' GetLastInputInfo API
however, this can't works whenever user logged on as different using Windows XP Fast User Switching, and eventho' GetLastInputInfo returns true, but variable it returns will remain unchanged

here code snippet of the apps:

HWINSTA hWinSta = OpenWindowStation("WinSta0", FALSE,
	READ_CONTROL | WRITE_DAC | WINSTA_ENUMDESKTOPS);
if (NULL != hWinSta)
	SetProcessWindowStation(hWinSta);

hDesktop = OpenInputDesktop(0, FALSE,
	READ_CONTROL | WRITE_DAC | DESKTOP_HOOKCONTROL);
if (NULL != hDesktop)
	SetThreadDesktop(hDesktop);

lii.cbSize = sizeof(LASTINPUTINFO);
BOOL ret = GetLastInputInfo(&lii);


i've tried switching to active input desktop (i've tried using OpenDesktop("default", 0, ...) as well, but still same), and even tho' ret always have TRUE value, but lii.dwTime is always stay unchanged
any help will be greatly appreciated. thanks

Garock
Newbie Poster
5 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

According to MSDN :
"This function is useful for input idle detection. However, GetLastInputInfo does not provide system-wide user input information across all running sessions. Rather, GetLastInputInfo provides session-specific user input information for only the session that invoked the function."

Even if that were not so, you are trying to do something that Windows was designed against. I can't imagine why you are trying to do this, but I suspect no one who knows how, if possible, has ever tried...

Sorry.

[EDIT] You might try using a global hook. See SetWindowsHookEx() for more.

Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
 

yup, previously i've been trying to use hook but it costs much of resources so i'm considering to use GetLastInputInfo instead
anw, thanks for your kind reply Duoas

Garock
Newbie Poster
5 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

or is there a way to open desktop handle to \Sessions\1\Windows\WindowStations\WinSta0\Default ?
since whenever i looked thru' process explorer (sysinternals), that window station for later sessions is not merely \Windows\WindowStation\WinSta0, but as stated above

using OpenWindowStation("\\Sessions\\1\\Windows\\WindowStations\\WinSta0") and OpenDesktop("\\Desktop") cannot get me desired result

Garock
Newbie Poster
5 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You