On Wed, Oct 13, 2004 at 10:49:55AM +0100, Dave Korn wrote: >> -----Original Message----- >> From: cygwin-owner On Behalf Of Daniel Miller >> Sent: 13 October 2004 01:57 > >> hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); ^^^^^^^^^^^^^^^^^ >> PERR(hStdOut != INVALID_HANDLE_VALUE, "GetStdHandle"); >> bSuccess = GetConsoleScreenBufferInfo(hStdOut, &sinfo) ; >> if (bSuccess == false) { >> // this returned "The handle is invalid" >> fprintf(stderr, "gcsbi error: %s\n", get_system_message()) ; >> exit(1) ; >> redirected = 1 ; >> return ; >> } > > Hmm. That's the first time I've heard of GetConsoleScreenBufferInfo. >Let's see what MSDN says about it: > >------------------------------<fairuse>------------------------------ >The GetConsoleScreenBufferInfo function retrieves information about the >specified console screen buffer. >------------------------------<fairuse>------------------------------ >Parameters >hConsoleOutput >[in] Handle to a console screen buffer. The handle must have GENERIC_READ ^^^^^^^^^^^^ >access. >lpConsoleScreenBufferInfo
>Right. So I would suggest that all you can reasonably infer from >bSuccess being false is that the function failed. You are going one >step beyond that in deducing that if the function fails, the handle >must not be a console screen buffer handle. There are of course other >reasons why the function might fail. You should have called >GetLastError, then you'd have more information about what was going on. Bingo. Like, maybe the STD_OUTPUT_HANDLE doesn't have GENERIC_READ access? cgf -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/