How to access windows in another session

1.5k views Asked by At

I am developing an application for observing other applications (including applications of another user sessions) My application should collect information about CPU loading, memory usage and state of main window (if exists) of each application. Now I am trying to obtain window state of other application. If its window is in the same session (as my application) then everything is OK.

And... I have a problem with obtaining info about windows in another session. I have read this old topic: How can I enumerate the open windows (~EnumWindows) of another user session and I understood that I should start new process within each session in order to enumerate windows in this session's desktop.

But maybe in Windows Server 2012 appeared a new solution(s) for this issue (some new API functions or some interaction with dwm.exe in another session etc)? If some administrative permissions (and/or group policies) are needed, it is not a problem

Now I am using Process.MainWindowHandle property (that probably uses GetWindowThreadProcessId function).

Also I tried use OpenWindowStation("\Sessions\1\Windows\WindowStations\WinSta0") that returns error 161 (invalid path)

1

There are 1 answers

0
David Heffernan On

You need to execute your code in the desktop whose windows you wish to observe.