"Nadav" <Na***@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.com...
(*) The host is compiled as a Win32 project (windows based) so it doesn't
support the std consol output, I wonder how can I enable support of the
std
output for Win32 windows based projects?
Yes, you can. The o/s and runtime don't create a console for windowed
application but you can do that at any time with AllocConsole(). If you are
willing to use the console API in windows to write to, and read from, the
console then you are done. If you want to address the console use runtime
try this little bit of voodoo:
#include <io.h>
#include <stdio.h>
void DoIt()
{
int fd;
FILE *fp;
AllocConsole();
fd = _open_osfhandle( (long)GetStdHandle( STD_OUTPUT_HANDLE ), 0);
fp = _fdopen( fd, "w" );
*stdout = *fp;
setvbuf( stdout, NULL, _IONBF, 0 );
printf("This is a test");
}
This should work if called from an executable. It is not guaranteed to work
if you put it in a DLL but try to do output from the executable.
Even though it only explicitly wires the Win32 console handle to the C
runtime standard output device you should be able to use C++ I/O streams.
Regards,
Will