I have same user logged in into windows 7 station with several simultaneous sessions (like Concurrent RDP or log in at station and then via RDP).
UPDATE: Ok, my research in this question has been stuck at this point (python example to write less complicated code):
#!/usr/bin/env python
import ctypes
import ctypes.wintypes as wintypes
def enum_desktops():
GetProcessWindowStation = user32.GetProcessWindowStation
EnumDesktops = user32.EnumDesktopsW
EnumDesktopsProc = ctypes.WINFUNCTYPE(wintypes.BOOL, wintypes.LPWSTR, wintypes.LPARAM)
hwinsta = GetProcessWindowStation()
def foreach_desktop(desk_name, lparam):
print("Desktop %s"%desk_name)
return True
EnumDesktops(hwinsta, EnumDesktopsProc(foreach_desktop), desk_lparam)
This function prints information about "Default" and "Winlogon" dektops. If we try to enumerate window stations, we'll get only "WinSta0", while I can see potentially target process started on different logon session.
So, what should I use to find window for target Desktop?
daemon is not an option at this point at all.