Changeset 51172 in vbox for trunk/src/VBox/Installer/win/Stub
- Timestamp:
- Apr 30, 2014 12:29:47 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Installer/win/Stub/VBoxStub.cpp
r51171 r51172 19 19 * Header Files * 20 20 *******************************************************************************/ 21 #if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0501 22 # undef _WIN32_WINNT 23 # define _WIN32_WINNT 0x0501 /* AttachConsole() / FreeConsole(). */ 24 #endif 25 21 26 #include <Windows.h> 22 27 #include <commctrl.h> … … 58 63 #endif 59 64 60 #if def DEBUG61 /* Use an own console window if run in debugmode. */65 #ifndef TARGET_NT4 66 /* Use an own console window if run in verbose mode. */ 62 67 # define VBOX_STUB_WITH_OWN_CONSOLE 63 68 #endif … … 816 821 return RTMsgInitFailure(vrc); 817 822 } 818 819 #if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0501820 # ifndef VBOX_STUB_WITH_OWN_CONSOLE /* Use an own console window if run in debug mode. */821 if (!AllocConsole())822 {823 DWORD dwErr = GetLastError();824 ShowError("Unable to allocate console, error = %ld\n",825 dwErr);826 827 /* Close the mutex for this application instance. */828 CloseHandle(hMutexAppRunning);829 hMutexAppRunning = NULL;830 return RTEXITCODE_FAILURE;831 }832 # else833 if (!AttachConsole(ATTACH_PARENT_PROCESS))834 {835 DWORD dwErr = GetLastError();836 /* Does the program have a console to attach to? */837 if (dwErr != ERROR_INVALID_HANDLE)838 {839 ShowError("Unable to attach to console, error = %ld\n",840 dwErr);841 842 /* Close the mutex for this application instance. */843 CloseHandle(hMutexAppRunning);844 hMutexAppRunning = NULL;845 return RTEXITCODE_FAILURE;846 }847 }848 # endif /* DEBUG */849 850 long lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);851 int iConHandleStdOut = _open_osfhandle(lStdHandle, _O_TEXT);852 FILE *hFileStdOut = _fdopen(iConHandleStdOut, "w");853 *stdout = *hFileStdOut;854 855 lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);856 int iConHandleStdErr = _open_osfhandle(lStdHandle, _O_TEXT);857 FILE *hFileStdErr = _fdopen(iConHandleStdErr, "w");858 *stderr = *hFileStdErr;859 860 setvbuf( stdout, NULL, _IONBF, 0 );861 862 #endif863 823 864 824 /* … … 1035 995 vrc = VERR_PARSE_ERROR; 1036 996 997 #if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0501 998 # ifdef VBOX_STUB_WITH_OWN_CONSOLE /* Use an own console window if run in debug mode. */ 999 if ( RT_SUCCESS(vrc) 1000 && g_iVerbosity) 1001 { 1002 if (!AllocConsole()) 1003 { 1004 DWORD dwErr = GetLastError(); 1005 ShowError("Unable to allocate console, error = %ld\n", 1006 dwErr); 1007 1008 /* Close the mutex for this application instance. */ 1009 CloseHandle(hMutexAppRunning); 1010 hMutexAppRunning = NULL; 1011 return RTEXITCODE_FAILURE; 1012 } 1013 1014 freopen("CONOUT$", "w", stdout); 1015 setvbuf(stdout, NULL, _IONBF, 0); 1016 1017 freopen("CONOUT$", "w", stderr); 1018 } 1019 # endif /* VBOX_STUB_WITH_OWN_CONSOLE */ 1020 #endif 1021 1037 1022 if ( RT_SUCCESS(vrc) 1038 1023 && g_iVerbosity) … … 1129 1114 1130 1115 #if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0501 1131 # ifndef VBOX_STUB_WITH_OWN_CONSOLE 1132 if (iConHandleStdErr) 1133 _close(iConHandleStdErr); 1134 if (hFileStdErr) 1135 fclose(hFileStdErr); 1136 if (iConHandleStdOut) 1137 _close(iConHandleStdOut); 1138 if (hFileStdOut) 1139 fclose(hFileStdOut); 1116 # ifdef VBOX_STUB_WITH_OWN_CONSOLE 1117 FreeConsole(); 1140 1118 # endif /* VBOX_STUB_WITH_OWN_CONSOLE */ 1141 FreeConsole();1142 1119 #endif 1143 1120
Note:
See TracChangeset
for help on using the changeset viewer.