|
-
June 16th, 2003, 02:35 PM
#1
Windows 2000 console trouble
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;
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() ) );
}
}
}
the i2cs function is a simpe integer to cstring function..
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 ??
ASCII stupid question, get a stupid ANSI.
When in Russia, pet a PETSCII.
Get your ass over to SLAYRadio the best station for C64 Remixes !
-
June 16th, 2003, 04:25 PM
#2
I am not 100% sure if I understood the question and I am no programmer (just hobby).
If you put a 'fetch();' before the return function it should leave you in the console waiting for a keypress.
It could be I am way outta line here but I hope this can help.
If I completely misunderstood the question let me know and I will remove the post.
-
June 16th, 2003, 04:31 PM
#3
Are you sure that it never opens the console window? In some cases it will open the window and then the window closes as soon as it opens. If you run a batch file from windows explorer it does a similar thing if there is no user input needed. Put a pause after the text is written to the console and see if that is the issue.
-
June 16th, 2003, 09:14 PM
#4
Nope..
I'll explain some more..
the software calculates some stuff and writes that to the console and to a file..
it's not a console application.. if some thing in the configuration is wrong, the main MFC screen appears and you can change settings..
the console is opened only when the calculating begins..
it did so on all versions of windows..
I updated windows 2000 and it doesn't do so anymore..
it's non interactive, so I don't need to fetch()
the only thing different since the update on the users windows 2000 computers is that theere is no console (it doesn't show).. the files get written and also the logfile (same as on console) is written..
via SMB i can even tail the file and thus via the network see what should be on their console..
the trouble is.. now they (the users) don't know when it is working..
if all else fails.. I'll write me another logfile system based on some tail code or something..
ASCII stupid question, get a stupid ANSI.
When in Russia, pet a PETSCII.
Get your ass over to SLAYRadio the best station for C64 Remixes !
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|