Commit de548725 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

regsvr32: Use OEM code page for output.

parent b111fab9
...@@ -41,7 +41,7 @@ static void WINAPIV output_write(UINT id, ...) ...@@ -41,7 +41,7 @@ static void WINAPIV output_write(UINT id, ...)
WCHAR fmt[1024]; WCHAR fmt[1024];
va_list va_args; va_list va_args;
WCHAR *str; WCHAR *str;
DWORD len, nOut, ret; DWORD len, nOut;
if (Silent) return; if (Silent) return;
...@@ -61,21 +61,19 @@ static void WINAPIV output_write(UINT id, ...) ...@@ -61,21 +61,19 @@ static void WINAPIV output_write(UINT id, ...)
return; return;
} }
ret = WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), str, len, &nOut, NULL);
/* WriteConsole fails if its output is redirected to a file. /* WriteConsole fails if its output is redirected to a file.
* If this occurs, we should use an OEM codepage and call WriteFile. * If this occurs, we should use an OEM codepage and call WriteFile.
*/ */
if (!ret) if (!WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), str, len, &nOut, NULL))
{ {
DWORD lenA; DWORD lenA;
char *strA; char *strA;
lenA = WideCharToMultiByte(GetConsoleOutputCP(), 0, str, len, NULL, 0, NULL, NULL); lenA = WideCharToMultiByte(GetOEMCP(), 0, str, len, NULL, 0, NULL, NULL);
strA = HeapAlloc(GetProcessHeap(), 0, lenA); strA = HeapAlloc(GetProcessHeap(), 0, lenA);
if (strA) if (strA)
{ {
WideCharToMultiByte(GetConsoleOutputCP(), 0, str, len, strA, lenA, NULL, NULL); WideCharToMultiByte(GetOEMCP(), 0, str, len, strA, lenA, NULL, NULL);
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), strA, lenA, &nOut, FALSE); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), strA, lenA, &nOut, FALSE);
HeapFree(GetProcessHeap(), 0, strA); HeapFree(GetProcessHeap(), 0, strA);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment