Click to See Complete Forum and Search --> : Need help with multiple users and active input desktop


Garock
November 13th, 2007, 02:20 AM
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
November 13th, 2007, 05:29 AM
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