Make WinVNC service mode work on Windows Vista and beyond.
Patch by Jochen Tucht, fixes bug 135.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5158 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/win/rfb_win32/LaunchProcess.cxx b/win/rfb_win32/LaunchProcess.cxx
index 56a712e..16ced64 100644
--- a/win/rfb_win32/LaunchProcess.cxx
+++ b/win/rfb_win32/LaunchProcess.cxx
@@ -44,10 +44,20 @@
await();
returnCode = STILL_ACTIVE;
+ DWORD size;
+ char desktopName[256];
+ char buf[256];
+ HDESK desktop = GetThreadDesktop(GetCurrentThreadId());
+ if (!GetUserObjectInformation(desktop, UOI_NAME, buf, 256, &size))
+ throw rdr::SystemException("unable to launch process", GetLastError());
+
+ snprintf(desktopName, 256, "WinSta0\\%s", buf);
+
// - Create storage for the process startup information
STARTUPINFO sinfo;
memset(&sinfo, 0, sizeof(sinfo));
sinfo.cb = sizeof(sinfo);
+ sinfo.lpDesktop = desktopName;
// - Concoct a suitable command-line
TCharArray exePath;