aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2011-04-04 17:11:56 +0000
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2011-04-04 17:11:56 +0000
commitb5b1f2dfbab55efb891a51e3032e29a30ed582c5 (patch)
treeeca59fdb6682042d4813567b9078c03523fddc05 /gtk
parent818fda61ce4cdb9d6ac004285f4a52708437c980 (diff)
On Windows, try to use an existing console for our messages. Create one if
it doesn't exist. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@36452 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'gtk')
-rw-r--r--gtk/main.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/gtk/main.c b/gtk/main.c
index 381cf17b71..ce5b50d66f 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -217,6 +217,7 @@ static guint tap_update_timer_id;
#ifdef _WIN32
static gboolean has_console; /* TRUE if app has console */
+static gboolean console_wait; /* "Press any key..." */
static void destroy_console(void);
static gboolean stdin_capture = FALSE; /* Don't grab stdin & stdout if TRUE */
#endif
@@ -3056,6 +3057,7 @@ WinMain (struct HINSTANCE__ *hInstance,
ws_load_library("riched20.dll");
has_console = FALSE;
+ console_wait = FALSE;
return main (__argc, __argv);
}
@@ -3086,8 +3088,19 @@ create_console(void)
if (!has_console) {
/* We have no console to which to print the version string, so
create one and make it the standard input, output, and error. */
- if (!AllocConsole())
- return; /* couldn't create console */
+
+ /*
+ * See if we have an existing console (i.e. we were run from a
+ * command prompt)
+ */
+ if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
+ if (AllocConsole()) {
+ SetConsoleTitle(_T("Wireshark Debug Console"));
+ console_wait = TRUE;
+ } else {
+ return; /* couldn't create console */
+ }
+ }
ws_freopen("CONIN$", "r", stdin);
ws_freopen("CONOUT$", "w", stdout);
@@ -3103,14 +3116,13 @@ create_console(void)
the message(s) we put in there). */
atexit(destroy_console);
- SetConsoleTitle(_T("Wireshark Debug Console"));
}
}
static void
destroy_console(void)
{
- if (has_console) {
+ if (console_wait) {
printf("\n\nPress any key to exit\n");
_getch();
FreeConsole();