Console output from GUI application

Hi all,

How can I attach to stdout/stderr of the console an MFC application was
run from?
CreateFile(“CON”, GENERIC_WRITE, …) results in ACCESS_DENIED.

There was a sample in Win32 SDK explaining how to do that, which I can’t
find now…

Thank you in advance.
Giga