add ConErrMessage to deal with error msg and ConOutMessage for other msg. Copy error...
authorMagnus Olsen <magnus@greatlord.com>
Tue, 19 Jul 2005 22:48:35 +0000 (22:48 +0000)
committerMagnus Olsen <magnus@greatlord.com>
Tue, 19 Jul 2005 22:48:35 +0000 (22:48 +0000)
svn path=/trunk/; revision=16651

reactos/subsys/system/cmd/cmd.h
reactos/subsys/system/cmd/console.c
reactos/subsys/system/cmd/internal.c

index a1a8e06..a90121f 100644 (file)
@@ -152,6 +152,7 @@ VOID ConErrChar (TCHAR);
 VOID ConErrPuts (LPTSTR);
 VOID ConErrPrintf (LPTSTR, ...);
 VOID ConOutFormatMessage (DWORD MessageId, ...);
+VOID ConErrFormatMessage (DWORD MessageId, ...);
 
 SHORT GetCursorX  (VOID);
 SHORT GetCursorY  (VOID);
index e9a5188..4adf010 100644 (file)
@@ -330,6 +330,35 @@ VOID ConPrintfPaging(BOOL NewPage, LPTSTR szFormat, va_list arg_ptr, DWORD nStdH
 #endif
 }
 
+VOID ConErrFormatMessage (DWORD MessageId, ...)
+{
+       TCHAR szMsg[RC_STRING_MAX_SIZE];
+       DWORD ret;
+       LPTSTR text;
+       va_list arg_ptr;
+
+       va_start (arg_ptr, MessageId);
+       ret = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+              NULL,
+              MessageId,
+              MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+              (LPTSTR) &text,
+              0,
+              &arg_ptr);
+
+       va_end (arg_ptr);
+       if(ret > 0)
+       {
+               ConErrPuts (text);
+               LocalFree(text);
+       }
+       else
+       {
+               LoadString(CMD_ModuleHandle, STRING_CONSOLE_ERROR, szMsg, RC_STRING_MAX_SIZE);
+               ConErrPrintf(szMsg);
+       }
+}
+
 VOID ConOutFormatMessage (DWORD MessageId, ...)
 {
        TCHAR szMsg[RC_STRING_MAX_SIZE];
@@ -349,13 +378,13 @@ VOID ConOutFormatMessage (DWORD MessageId, ...)
        va_end (arg_ptr);
        if(ret > 0)
        {
-               ConOutPuts (text);
+               ConErrPuts (text);
                LocalFree(text);
        }
        else
        {
                LoadString(CMD_ModuleHandle, STRING_CONSOLE_ERROR, szMsg, RC_STRING_MAX_SIZE);
-               ConOutPrintf(szMsg);
+               ConErrPrintf(szMsg);
        }
 }
 
index 3cc494b..8ec6bbc 100644 (file)
@@ -364,7 +364,7 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param)
        {
                if(hFile == INVALID_HANDLE_VALUE)
                {               
-                       ConOutFormatMessage (GetLastError(), szFinalPath);                      
+                       ConErrFormatMessage (GetLastError(), szFinalPath);                      
                        nErrorLevel = 1;
                        return 1;
                }