|
2 | 2 |
|
3 | 3 | #define WIN32_LEAN_AND_MEAN |
4 | 4 | #include <windows.h> |
5 | | -#include <fcntl.h> |
6 | 5 |
|
7 | 6 | #include "Python.h" |
8 | 7 |
|
9 | | -#ifdef LAUNCHER |
10 | | -/* Q105305 suggests this routine to adjust the handles. */ |
11 | | -static void adjust_file(DWORD handle, FILE* f, char* mode) |
12 | | -{ |
13 | | - int hCrt; |
14 | | - FILE *hf; |
15 | | - hCrt = _open_osfhandle((intptr_t)GetStdHandle(handle), _O_TEXT); |
16 | | - hf = _fdopen(hCrt, mode); |
17 | | - *f = *hf; |
18 | | - setvbuf(f, NULL, _IONBF, 0); |
19 | | - /* Alternatively, we could use __set_app_type and _set_osfhnd, |
20 | | - but that appears to be undocumented. */ |
21 | | -} |
22 | | -#endif |
23 | | - |
24 | 8 | int WINAPI WinMain( |
25 | 9 | HINSTANCE hInstance, /* handle to current instance */ |
26 | 10 | HINSTANCE hPrevInstance, /* handle to previous instance */ |
27 | 11 | LPSTR lpCmdLine, /* pointer to command line */ |
28 | 12 | int nCmdShow /* show state of window */ |
29 | 13 | ) |
30 | 14 | { |
31 | | -#ifdef LAUNCHER |
32 | | - int i; |
33 | | - if (__argc > 1 && strcmp(__argv[1], "-console") == 0) { |
34 | | - /* Allocate a console, and remove the -console argument. */ |
35 | | - AllocConsole(); |
36 | | - for (i = 2; i < __argc; i++) |
37 | | - __argv[i-1] = __argv[i]; |
38 | | - __argc--; |
39 | | - /* Make stdin, stdout, stderr use the newly allocated OS handles. */ |
40 | | - adjust_file(STD_INPUT_HANDLE, stdin, "r"); |
41 | | - adjust_file(STD_OUTPUT_HANDLE, stdout, "w"); |
42 | | - adjust_file(STD_ERROR_HANDLE, stderr, "w"); |
43 | | - } |
44 | | -#endif |
45 | 15 | return Py_Main(__argc, __argv); |
46 | 16 | } |
0 commit comments