use FormatMessage() to print some error messages. Patch by Michael Fritscher.

svn path=/trunk/; revision=9801
This commit is contained in:
Thomas Bluemel 2004-06-21 18:57:22 +00:00
parent ae0bc4e939
commit 8d5c063840
4 changed files with 21 additions and 6 deletions

View file

@ -1,4 +1,4 @@
/* $Id: cmd.c,v 1.15 2004/06/06 17:33:13 hbirr Exp $
/* $Id: cmd.c,v 1.16 2004/06/21 18:57:22 weiden Exp $
*
* CMD.C - command-line interface.
*
@ -1334,7 +1334,7 @@ int main (int argc, char *argv[])
OPEN_EXISTING, 0, NULL);
if (GetConsoleScreenBufferInfo(hConsole, &Info) == FALSE)
{
ConErrPrintf (_T("GetConsoleScreenBufferInfo: Error: %ld\n"), GetLastError());
ConOutFormatMessage(GetLastError());
return(1);
}
wColor = Info.wAttributes;

View file

@ -1,4 +1,4 @@
/* $Id: cmd.h,v 1.4 2003/12/26 09:52:37 navaraf Exp $
/* $Id: cmd.h,v 1.5 2004/06/21 18:57:22 weiden Exp $
*
* CMD.H - header file for the modules in CMD.EXE
*
@ -170,6 +170,7 @@ VOID ConOutPrintf (LPTSTR, ...);
VOID ConErrChar (TCHAR);
VOID ConErrPuts (LPTSTR);
VOID ConErrPrintf (LPTSTR, ...);
VOID ConOutFormatMessage (DWORD MessageId, ...);
SHORT GetCursorX (VOID);
SHORT GetCursorY (VOID);

View file

@ -1,4 +1,4 @@
/* $Id: console.c,v 1.5 2004/04/30 16:52:41 navaraf Exp $
/* $Id: console.c,v 1.6 2004/06/21 18:57:22 weiden Exp $
*
* CONSOLE.C - console input/output functions.
*
@ -223,6 +223,20 @@ VOID ConPrintf(LPTSTR szFormat, va_list arg_ptr, DWORD nStdHandle)
#endif
}
VOID ConOutFormatMessage (DWORD MessageId, ...)
{
DWORD temp;
LPTSTR text;
va_list arg_ptr;
temp = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
MessageId,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &text,
0,
&arg_ptr);
ConErrPrintf (text);
}
VOID ConOutPrintf (LPTSTR szFormat, ...)
{

View file

@ -247,8 +247,8 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param)
if (!SetCurrentDirectory (dir))
{
//ErrorMessage (GetLastError(), _T("CD"));
ConErrPrintf (_T("Dir \"%s\" doesn't seem to exist!"),dir);
ConOutFormatMessage(GetLastError());
/* throw away current directory */
free (lpOldPath);
lpOldPath = NULL;