When I have a Win32 non-console application (AFAIK, the console-ness of a Win32 app is linked into the exe), starting it from the console cmd.exe
will return to the command prompt immediately, running the application "in the background" (o.c. it can have a GUI of sorts, or even open its own console window)
Is it possible in the non-console executable to detect that it was launched from cmd.exe and "attach" it to the launching cmd.exe?
And note that there are various questions/answers related to this, but it seems that this exact approach hasn't been investigated. (Maybe it's not possible like that.)
You can do this very easily. Simply pass ATTACH_PARENT_PROCESS
to AttachConsole
.
Whether or not the end result is sensible or practical is something I could not say. Both processes would read and write to the same console which could get pretty weird.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With