diff --git a/reactos/subsys/system/cmd/cls.c b/reactos/subsys/system/cmd/cls.c index e6a5991d0ec..9e6bbba3059 100644 --- a/reactos/subsys/system/cmd/cls.c +++ b/reactos/subsys/system/cmd/cls.c @@ -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; diff --git a/reactos/subsys/system/cmd/cmd.c b/reactos/subsys/system/cmd/cmd.c index 6cf138b4ffd..177e1d8c880 100644 --- a/reactos/subsys/system/cmd/cmd.c +++ b/reactos/subsys/system/cmd/cmd.c @@ -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; diff --git a/reactos/subsys/system/cmd/cmd.h b/reactos/subsys/system/cmd/cmd.h index 6754b383d32..d68e1674d11 100644 --- a/reactos/subsys/system/cmd/cmd.h +++ b/reactos/subsys/system/cmd/cmd.h @@ -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; diff --git a/reactos/subsys/system/cmd/color.c b/reactos/subsys/system/cmd/color.c index 1ee7b151e53..4eefc3fb9cb 100644 --- a/reactos/subsys/system/cmd/color.c +++ b/reactos/subsys/system/cmd/color.c @@ -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)); } diff --git a/reactos/subsys/system/cmd/console.c b/reactos/subsys/system/cmd/console.c index 1d9c4bb6c72..8cfec8e1224 100644 --- a/reactos/subsys/system/cmd/console.c +++ b/reactos/subsys/system/cmd/console.c @@ -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;