Suppose Fred runs a program on his windows desktop, if the program queries the username it can see it is 'Fred'. If he uses 'run as' 'Jane' instead, then the program will report 'Jane' as the user. However in this case the program needs to know which desktop instance it is running on, how can it find out?
This question is similar to others but there is a security hurdle. Fred is an admin, Jane is not.
The program 'run as' Jane can not query the session using WTSQuerySessionInformation (WTS_CURRENT_SERVER_HANDLE, id, ...) when running from Fred's desktop because of permissions. The reverse is not true. Is there any other way I can query what desktop I'm executing on that doesn't have this issue?