I wrote a Windows service. It is running at the system level. I used the following code to get the logged in user's username. But I want to get an environment variable for that user session. How can I do that?
DWORD sessionId = WTSGetActiveConsoleSessionId();
qInfo() << "session id = " << sessionId;
wchar_t* ppBuffer[100];
DWORD bufferSize;
WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, sessionId, WTSUserName, ppBuffer, &bufferSize);
qInfo() << "Windows User Name = " << QString::fromWCharArray(*ppBuffer);