Why would I want to? Because I'm writing my own cmd.exe replacement! I can CreateProcess and pass in handles to pipes for stdin and stdout and stderr, and I see how I can AllocConsole, FreeConsole, and AttachConsole, but how do I tell child programs that my program is the console?
More detail for clarification: I've got a window that can display text and accept input. I display the text "C:>" for instance. The user types "foo.exe". I locate foo.exe on the path, and call CreateProcess on it. If it writes to stdout, I display that text on the screen. If it reads from stdin, I pass in whatever keystrokes the user has pressed. When the process terminates, I print the prompt again. So far, so good. It all works. But then I try foo2.exe, which does a CreateFile on CONOUT$, which fails because there is no console attached to the process. What does cmd.exe do to make it's children see it as a console?