Commit 950f32c4 authored by Martin Schultz's avatar Martin Schultz

ttach Openflipper to running parent console if possible

parent e74c7b1a
...@@ -117,6 +117,18 @@ ...@@ -117,6 +117,18 @@
#endif #endif
#ifdef WIN32 #ifdef WIN32
void attachExistingConsole()
{
//try to attach the console of the parent process
if (AttachConsole(-1))
{
//if the console was attached change stdinput and output
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
}
}
#ifdef WIN_GET_DEBUG_CONSOLE #ifdef WIN_GET_DEBUG_CONSOLE
void getConsole() { void getConsole() {
//Create a console for this application //Create a console for this application
...@@ -371,6 +383,7 @@ int main(int argc, char **argv) ...@@ -371,6 +383,7 @@ int main(int argc, char **argv)
OpenFlipper::Options::windowTitle(TOSTRING(PRODUCT_STRING)" v" + OpenFlipper::Options::coreVersion()); OpenFlipper::Options::windowTitle(TOSTRING(PRODUCT_STRING)" v" + OpenFlipper::Options::coreVersion());
#ifdef WIN32 #ifdef WIN32
attachExistingConsole();
#ifdef WIN_GET_DEBUG_CONSOLE #ifdef WIN_GET_DEBUG_CONSOLE
getConsole(); getConsole();
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment