On Sun, Oct 21, 2001 at 01:09:28AM -0700, Augustus Saunders wrote: >Christopher Fayler wrote: >>FWIW, this is exact problem plagues the Windows version of insight (aka >>gdb). The only solution we ever came up with was either to call >>AllocConsole when we needed to write something to a console -- which >>sucks for when you're starting the program via the console, or to build >>the program as a console app -- which means that you always get a >>flashing black box if you double click on a gdb icon. >> >>It *looks* like the MSVC program somehow manages to do what we want >>here since it seems to exist as both a console and a windows app but I >>was never able to figure out how to do what it did. Most likely, I am >>just misinterpreting what it does do. > > >Chris, if I understand you correctly, then you want the (GUI) >application to detect whether or not it was launched from an existing >shell and then to use the shell it was run from for its console. >Otherwise, you want to spawn a new console. IIRC, when an application >is launched from a console, then you can just use standard in and >standard out and it works as if by magic.
Have you tried this? If you link a program with -mwindows and do a "printf" in the program, nothing shows up on the console. If you do an "AllocConsole" prior to the printf then a new console window opens up and your message will be displayed there. >I would also mention that there is an AttachConsole where you can use >an already existing console, you just have to know the console owner's >PID. The MSDN documentation indicates that AttachConsole is available on Windows XP only. It's not a generic solution. >One last thing I tripped over, if things don't "just work": > >http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/prothred_4uus.asp > >This shows how you can reroute a child process's standard in and out to >pipes, which you can then do whatever you want with. Not saying you >want to do this, but it might give you some other ideas. cgf
