1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| void start_console() {
BOOL bret;
HANDLE hout;
int iout;
FILE *fout;
bret = AllocConsole();
if (!bret)
throw "failed to allocate console";
hout = GetStdHandle(STD_OUTPUT_HANDLE);
if (hout == INVALID_HANDLE_VALUE)
throw "failed to retreive standard handle";
iout = _open_osfhandle((long) hout, _O_WRONLY | _O_TEXT);
if (iout == -1)
throw "failed to convert to io handle";
fout = _fdopen(iout, "wt");
if (fout == NULL)
throw "failed to convert to FILE handle";
*stdout = *fout;
} |
Partager