| 543 |
543 |
| 544 /* If debug or help or version flag used, create console for output */ |
544 /* If debug or help or version flag used, create console for output */ |
| 545 if (strstr(lpszCmdLine, "-d") || strstr(lpszCmdLine, "-h") || strstr(lpszCmdLine, "-v")) { |
545 if (strstr(lpszCmdLine, "-d") || strstr(lpszCmdLine, "-h") || strstr(lpszCmdLine, "-v")) { |
| 546 /* If stdout hasn't been redirected to a file, alloc a console |
546 /* If stdout hasn't been redirected to a file, alloc a console |
| 547 * (_istty() doesn't work for stuff using the GUI subsystem) */ |
547 * (_istty() doesn't work for stuff using the GUI subsystem) */ |
| 548 if (_fileno(stdout) == -1) { |
548 if (_fileno(stdout) == -1 || _fileno(stdout) == -2) { |
| 549 LPFNATTACHCONSOLE MyAttachConsole = NULL; |
549 LPFNATTACHCONSOLE MyAttachConsole = NULL; |
| 550 if ((hmod = GetModuleHandle("kernel32.dll"))) { |
550 if ((hmod = GetModuleHandle("kernel32.dll"))) { |
| 551 MyAttachConsole = |
551 MyAttachConsole = |
| 552 (LPFNATTACHCONSOLE) |
552 (LPFNATTACHCONSOLE) |
| 553 GetProcAddress(hmod, "AttachConsole"); |
553 GetProcAddress(hmod, "AttachConsole"); |