My C++ Service application (which is created by regular user, not SYSTEM, not LOCAL SERVICE) spawns Windows Console. Via Windows' Task Manager, I do see that console but I cannot bring it to front. Via ProcessExplorer (procexp.exe), I do see that console and I can bring it to front.
Here is the relevant code, do I miss some kind of weird setting which can satisfy Windows' Task Manager?:
HANDLE hToken = NULL;
BOOL bRet = WTSQueryUserToken(WTSGetActiveConsoleSessionId(), &hToken);
if (!bRet)
{
DWORD err = GetLastError();
hToken = NULL;
}
ZeroMemory( &pi,sizeof(pi));
ZeroMemory( &si, sizeof( STARTUPINFO ) );
si.cb = sizeof( STARTUPINFO );
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USECOUNTCHARS;
si.dwXCountChars = (DWORD)pod->od.width-1;
si.dwYCountChars = (DWORD)9999;
si.lpTitle = (LPSTR)pod->od.title;
si.wShowWindow = SW_NORMAL;
si.lpDesktop = (LPSTR)"winsta0\\default";
const BOOL success = CreateProcessAsUser(hToken,NULL,command,NULL,NULL,TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi);