mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
- Open CONOUT$ for accessing the console buffer. This fixes the
"GetConsolScreenBufferInfo : error 6" message, if the stdout handle is redirected. svn path=/trunk/; revision=4810
This commit is contained in:
parent
f170e40b0a
commit
ec5e98348c
5 changed files with 21 additions and 20 deletions
|
@ -46,17 +46,17 @@ INT cmd_cls (LPTSTR cmd, LPTSTR param)
|
|||
return 0;
|
||||
}
|
||||
|
||||
GetConsoleScreenBufferInfo (hOut, &csbi);
|
||||
GetConsoleScreenBufferInfo (hConsole, &csbi);
|
||||
|
||||
coPos.X = 0;
|
||||
coPos.Y = 0;
|
||||
FillConsoleOutputAttribute (hOut, wColor,
|
||||
FillConsoleOutputAttribute (hConsole, wColor,
|
||||
(csbi.dwSize.X)*(csbi.dwSize.Y),
|
||||
coPos, &dwWritten);
|
||||
FillConsoleOutputCharacter (hOut, _T(' '),
|
||||
FillConsoleOutputCharacter (hConsole, _T(' '),
|
||||
(csbi.dwSize.X)*(csbi.dwSize.Y),
|
||||
coPos, &dwWritten);
|
||||
SetConsoleCursorPosition (hOut, coPos);
|
||||
SetConsoleCursorPosition (hConsole, coPos);
|
||||
|
||||
bIgnoreEcho = TRUE;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: cmd.c,v 1.2 2003/04/26 16:38:05 ekohl Exp $
|
||||
/* $Id: cmd.c,v 1.3 2003/06/01 17:06:22 hbirr Exp $
|
||||
*
|
||||
* CMD.C - command-line interface.
|
||||
*
|
||||
|
@ -144,6 +144,7 @@ DWORD dwChildProcessId = 0;
|
|||
OSVERSIONINFO osvi;
|
||||
HANDLE hIn;
|
||||
HANDLE hOut;
|
||||
HANDLE hConsole;
|
||||
|
||||
#ifdef INCLUDE_CMD_COLOR
|
||||
WORD wColor; /* current color */
|
||||
|
@ -1163,14 +1164,13 @@ int main (int argc, char *argv[])
|
|||
SetFileApisToOEM();
|
||||
|
||||
AllocConsole();
|
||||
if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &Info) == FALSE)
|
||||
hConsole = CreateFile("CONOUT$", GENERIC_READ|GENERIC_WRITE,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
|
||||
OPEN_EXISTING, 0, NULL);
|
||||
if (GetConsoleScreenBufferInfo(hConsole, &Info) == FALSE)
|
||||
{
|
||||
fprintf(stderr, "GetConsoleScreenBufferInfo: Error: %ld\n", GetLastError());
|
||||
#ifndef __REACTOS__
|
||||
/* On ReactOS GetConsoleScreenBufferInfo returns an error if the stdin
|
||||
handle is redirected to a pipe or file. This stops windres from working. */
|
||||
return(1);
|
||||
#endif
|
||||
}
|
||||
wColor = Info.wAttributes;
|
||||
wDefColor = wColor;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: cmd.h,v 1.1 2003/03/20 19:19:22 rcampbell Exp $
|
||||
/* $Id: cmd.h,v 1.2 2003/06/01 17:06:22 hbirr Exp $
|
||||
*
|
||||
* CMD.H - header file for the modules in CMD.EXE
|
||||
*
|
||||
|
@ -76,6 +76,7 @@
|
|||
/* global variables */
|
||||
extern HANDLE hOut;
|
||||
extern HANDLE hIn;
|
||||
extern HANDLE hConsole;
|
||||
extern WORD wColor;
|
||||
extern WORD wDefColor;
|
||||
extern BOOL bCtrlBreak;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: color.c,v 1.1 2003/03/20 19:19:22 rcampbell Exp $
|
||||
/* $Id: color.c,v 1.2 2003/06/01 17:06:22 hbirr Exp $
|
||||
*
|
||||
* COLOR.C - color internal command.
|
||||
*
|
||||
|
@ -70,17 +70,17 @@ VOID SetScreenColor (WORD wColor, BOOL bFill)
|
|||
|
||||
if (bFill == TRUE)
|
||||
{
|
||||
GetConsoleScreenBufferInfo (hOut, &csbi);
|
||||
GetConsoleScreenBufferInfo (hConsole, &csbi);
|
||||
|
||||
coPos.X = 0;
|
||||
coPos.Y = 0;
|
||||
FillConsoleOutputAttribute (hOut,
|
||||
FillConsoleOutputAttribute (hConsole,
|
||||
(WORD)(wColor & 0x00FF),
|
||||
(csbi.dwSize.X)*(csbi.dwSize.Y),
|
||||
coPos,
|
||||
&dwWritten);
|
||||
}
|
||||
SetConsoleTextAttribute (hOut, (WORD)(wColor & 0x00FF));
|
||||
SetConsoleTextAttribute (hConsole, (WORD)(wColor & 0x00FF));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: console.c,v 1.1 2003/03/20 19:19:22 rcampbell Exp $
|
||||
/* $Id: console.c,v 1.2 2003/06/01 17:06:22 hbirr Exp $
|
||||
*
|
||||
* CONSOLE.C - console input/output functions.
|
||||
*
|
||||
|
@ -249,7 +249,7 @@ VOID GetCursorXY (PSHORT x, PSHORT y)
|
|||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
|
||||
GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &csbi);
|
||||
GetConsoleScreenBufferInfo (hConsole, &csbi);
|
||||
|
||||
*x = csbi.dwCursorPosition.X;
|
||||
*y = csbi.dwCursorPosition.Y;
|
||||
|
@ -260,7 +260,7 @@ SHORT GetCursorX (VOID)
|
|||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
|
||||
GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &csbi);
|
||||
GetConsoleScreenBufferInfo (hConsole, &csbi);
|
||||
|
||||
return csbi.dwCursorPosition.X;
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ SHORT GetCursorY (VOID)
|
|||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
|
||||
GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &csbi);
|
||||
GetConsoleScreenBufferInfo (hConsole, &csbi);
|
||||
|
||||
return csbi.dwCursorPosition.Y;
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ VOID GetScreenSize (PSHORT maxx, PSHORT maxy)
|
|||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
|
||||
GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &csbi);
|
||||
GetConsoleScreenBufferInfo (hConsole, &csbi);
|
||||
|
||||
if (maxx)
|
||||
*maxx = csbi.dwSize.X;
|
||||
|
|
Loading…
Reference in a new issue