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

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.

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

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

This article has been dead for over six months. Start a new discussion instead.