wtsapi32

How can I get the current user token for the physical session?

I have some code, with which I'm trying to get the current session user token: #include <Wtsapi32.h> DWORD activeSessionId = WTSGetActiveConsoleSessionId(); HANDLE currentToken; BOOL queryRet = WTSQueryUserToken(activeSessionId, &currentToken); if (!queryRet) { DWORD err = GetLastError(); return 0; } Value of err is 1314. Update...

How do I enumerate open windows in a different session from a service?

I've seen this question, but I was hoping to avoid using CreateProcessAsUser. I can enumerate windows by calling EnumDesktopWindows, and I can get the desktops by calling EnumDesktops. Unfortunately, EnumDesktops requires a window station name, and WTSQuerySessionInformation with WTSWinStationName explicitly does not return the window st...

WTSQuerySessionInformation returning empty strings

I've written a program which should query the Terminal Services API and print out some state information about the sessions running on a terminal services box. I'm using the WTSQuerySessionInformation function to do this and it's returning some data but most of the data seems to be missing... Does anyone know why? Here's my program: v...