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/winvnc/winvnc.cxx b/win/winvnc/winvnc.cxx
index 1df0f76..4aa5dcb 100644
--- a/win/winvnc/winvnc.cxx
+++ b/win/winvnc/winvnc.cxx
@@ -43,7 +43,7 @@
TStr rfb::win32::AppName("VNC Server");
-static bool runAsService = false;
+extern bool runAsService;
static bool runServer = true;
static bool close_console = false;
@@ -159,6 +159,11 @@
MsgBoxOrLog(result.buf);
} else if (strcasecmp(argv[i], "-service") == 0) {
printf("Run in service mode\n");
+ runServer = false;
+ runAsService = true;
+
+ } else if (strcasecmp(argv[i], "-service_run") == 0) {
+ printf("Run in service mode\n");
runAsService = true;
} else if (strcasecmp(argv[i], "-register") == 0) {
@@ -255,16 +260,11 @@
if (runServer) {
// Start the network subsystem and run the server
VNCServerWin32 server;
-
- if (runAsService) {
- printf("Starting Service-Mode VNC Server.\n");
- VNCServerService service(server);
- service.start();
- result = service.getStatus().dwWin32ExitCode;
- } else {
- printf("Starting User-Mode VNC Server.\n");
- result = server.run();
- }
+ result = server.run();
+ } else if (runAsService) {
+ VNCServerService service;
+ service.start();
+ result = service.getStatus().dwWin32ExitCode;
}
vlog.debug("WinVNC service destroyed");