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 DWORD activeSessionId = WTSGetActiveConsoleSessionId(); HANDLE currentToken; BOOL queryRet = WTSQueryUserToken(activeSessionId, ¤tToken); if (!queryRet) { DWORD err = GetLastError(); return 0; } Value of err is 1314. Update 1 No luck so far, tried to grant the current process SE_TCB_NAME - but still get same error from WTSQueryUserToken (1314). HANDLE process = GetCurrentProcess(); HANDLE processToken; BOOL openTokenRet = OpenProcessToken( process,