diff options
author | Pierre Ossman <ossman@cendio.se> | 2015-02-17 13:23:00 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2015-02-17 13:23:00 +0100 |
commit | 5bf17addcb1ea4dcf3d3306bdcb3b4288a7cb007 (patch) | |
tree | 237f16bc3620c714defaaaad1241b1884a5658c5 /vncviewer/vncviewer.cxx | |
parent | 3c76a6d1eb6b375bdf973ff88988b12d12528bea (diff) | |
download | tigervnc-5bf17addcb1ea4dcf3d3306bdcb3b4288a7cb007.tar.gz tigervnc-5bf17addcb1ea4dcf3d3306bdcb3b4288a7cb007.zip |
Create a console window for help output on Windows
Diffstat (limited to 'vncviewer/vncviewer.cxx')
-rw-r--r-- | vncviewer/vncviewer.cxx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx index d980ed2c..5f1b980c 100644 --- a/vncviewer/vncviewer.cxx +++ b/vncviewer/vncviewer.cxx @@ -29,6 +29,7 @@ #include <errno.h> #include <signal.h> #include <locale.h> +#include <fcntl.h> #include <sys/stat.h> #ifdef WIN32 @@ -261,6 +262,20 @@ static void mkvnchomedir() static void usage(const char *programName) { +#ifdef WIN32 + // If we don't have a console then we need to create one for output + if (GetConsoleWindow() == NULL) { + HANDLE handle; + int fd; + + AllocConsole(); + + handle = GetStdHandle(STD_ERROR_HANDLE); + fd = _open_osfhandle((intptr_t)handle, O_TEXT); + *stderr = *fdopen(fd, "w"); + } +#endif + fprintf(stderr, "\nusage: %s [parameters] [host:displayNum] [parameters]\n" " %s [parameters] -listen [port] [parameters]\n", @@ -273,6 +288,12 @@ static void usage(const char *programName) "--<param>=<value>\n" "Parameter names are case-insensitive. The parameters are:\n\n"); Configuration::listParams(79, 14); + +#ifdef WIN32 + // Just wait for the user to kill the console window + Sleep(INFINITE); +#endif + exit(1); } |