In some software I (co)wrote we use a console for the output..
this worked well on win95, 98, nt, 200 and XP !!
Rescently (after some windows 2000 update) we don't get the console anymore..
the data gets written, there is just no visual confirmation..
the code used for the console ( MS VC++ ) gets close to this..
in the initialisation I have a
HANDLE h_console = NULL;
the i2cs function is a simpe integer to cstring function..Code:void consolefunction() { if ( h_console == NULL ) { if ( AllocConsole() ) { h_console = GetStdHandle(STD_OUTPUT_HANDLE); if ( h_console == INVALID_HANDLE_VALUE ) { h_console = NULL; AfxMessageBox( "Message by JNL_CONSOLE:\n" "Unable to allocate console for display." ); return; } } else { AfxMessageBox( "Message by JNL_CONSOLE:\n" "Unable to allocate console.\n" "Reason: error " + i2cs( GetLastError() ) ); return; } } CString cs = "aaaaaaaaaaaaa\n"; if ( h_console != NULL ) { unsigned long l1 = 0; unsigned long l2 = 0; DWORD l = cs.GetLength(); BOOL b = WriteConsole( h_console , cs.GetBuffer( 0 ) , l , &l1 , &l2 ); if ( b == FALSE ) { AfxMessageBox( "Unable to write to console.\n" "Reason: error " + i2cs( GetLastError() ) ); } } }
Code:CString i2cs( int i ) { char ch[ 30 ]; itoa( i , ch , 10 ); return ch; }
running the consolefunction will print "aaaaaaaaa" in the created console screen, or creates one and prints "aaaaaaaa" ..
this works on all versions of windows except for a rescently updated windows2000
anyone know a good workaround / solution ??




Reply With Quote