HANDLE m_hConsoleOutput = NULL; if (!m_hConsoleOutput) { AllocConsole(); m_hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE); char str[512] = "start Console Log...\n"; WriteConsole(m_hConsoleOutput, str, strlen(str), NULL, NULL); } if (m_hConsoleOutput) { char str[512] = "destroy console...\n"; WriteConsole(m_hConsoleOutput, str, strlen(str), NULL, NULL); CloseHandle(m_hConsoleOutput); FreeConsole(); }