소스 검색

Show 'usage' information on console also for Windows

bel 11 년 전
부모
커밋
51971ce6c7
1개의 변경된 파일9개의 추가작업 그리고 0개의 파일을 삭제
  1. 9 0
      src/main.c

+ 9 - 0
src/main.c

@@ -134,6 +134,15 @@ static void show_usage_and_exit(void)
     const struct mg_option *options;
     int i;
 
+#ifdef WIN32
+    if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
+        AllocConsole();
+        AttachConsole(GetCurrentProcessId());
+    }
+    freopen("CON", "a", stdout);
+    freopen("CON", "a", stderr);
+#endif
+
     fprintf(stderr, "Civetweb v%s, built on %s\n",
             mg_version(), __DATE__);
     fprintf(stderr, "Usage:\n");