23 auto out_handle = GetStdHandle(STD_OUTPUT_HANDLE);
25 if (out_handle == NULL) {
29 if (AttachConsole(ATTACH_PARENT_PROCESS)) {
36 FILE *fpstdin = stdin;
37 FILE *fpstdout = stdout;
38 FILE *fpstderr = stderr;
40 freopen_s(&fpstdin,
"CONIN$",
"r", stdin);
41 freopen_s(&fpstdout,
"CONOUT$",
"w", stdout);
42 freopen_s(&fpstderr,
"CONOUT$",
"w", stderr);
46 auto stdin_handle = CreateFileW(L
"CONIN$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
47 SetStdHandle(STD_INPUT_HANDLE, stdin_handle);
49 auto stdout_handle = CreateFileW(L
"CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
50 SetStdHandle(STD_OUTPUT_HANDLE, stdout_handle);
51 SetStdHandle(STD_ERROR_HANDLE, stdout_handle);