Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Date: Mon, 29 Oct 2001 19:43:50 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: .*Console.* Functions vs. tty Message-ID: <20011029194350.Q891@cygbert.vinschen.de> Mail-Followup-To: cygwin AT cygwin DOT com References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from rdparker@butlermfg.com on Mon, Oct 29, 2001 at 12:29:32PM -0600 On Mon, Oct 29, 2001 at 12:29:32PM -0600, Parker, Ron wrote: > I am working on a program that offers a choice of user interfaces at run > time, similar to what xemacs does. This application is designed to be > portable at least between cygwin, Linux, and native Windows. One of the > UI's uses the standard console interfaces. However, when the code runs > under cygwin with "tty" enabled, I cannot get the console screen buffer > information. This is not dependent upon it being a cygwin compiled > application. It "malfunctions" if compiled by gcc for cygwin, gcc for > MinGW, or MSVC. > > I have narrowed the problem down to a simple portion of code, which will > exhibit the same behavior as my application. The GetConsoleScreenBufferInfo > function fails with error 6, ERROR_INVALID_HANDLE. > > How can I work around this without forcing the user to use "notty"? > > #include > > int main() > { > int retval = 0; > CONSOLE_SCREEN_BUFFER_INFO csbi; > > HANDLE output = GetStdHandle(STD_OUTPUT_HANDLE); According to MSDN you need a handle with GENERIC_READ access to call GetConsoleScreenBufferInfo with. That's not necessarily true for an output handle... Corinna > > AllocConsole(); > if (output == INVALID_HANDLE_VALUE) > { > printf("GetStdHandle failed: %ld\n", GetLastError()); > retval = 1; > } > else if (!GetConsoleScreenBufferInfo(output, &csbi)) > { > printf("GetConsoleScreenBufferInfo failed: %ld\n", GetLastError()); > retval = 2; > } > else > printf("Success."); > > return retval; > } > > > -- > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple > Bug reporting: http://cygwin.com/bugs.html > Documentation: http://cygwin.com/docs.html > FAQ: http://cygwin.com/faq/ -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Developer mailto:cygwin AT cygwin DOT com Red Hat, Inc. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/