At first glance it seems like the AttachConsole()
function will let you attach to the console of your parent process:
AttachConsole(ATTACH_PARENT_PROCESS);
If the process doesn't actually have a console the function will fail with ERROR_INVALID_HANDLE
. The function will also fail if your parent process no longer exists. If it fails you can then call AllocConsole()
to create your own.
I've never tried this so don't actually know if it will work or not :)