[PATCH 2/3] uninstaller: Add WriteFile fallback
Hugh McMaster
hugh.mcmaster at outlook.com
Mon May 25 00:56:05 CDT 2015
---
programs/uninstaller/main.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/programs/uninstaller/main.c b/programs/uninstaller/main.c
index f2ab82d..f549372 100644
--- a/programs/uninstaller/main.c
+++ b/programs/uninstaller/main.c
@@ -66,7 +66,21 @@ static void WINEPROG_writeconsole(const WCHAR *str, int wlen)
ret = WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), str, wlen, &count, NULL);
if (!ret)
- WINE_WARN("uninstaller: WriteConsole() failed.\n");
+ {
+ DWORD len;
+ char *ascii_string;
+
+ /* WriteConsole() fails on Windows if its output is redirected to a file.
+ * If this occurs, we should call WriteFile() and use an OEM codepage. */
+ len = WideCharToMultiByte(GetConsoleOutputCP(), 0, str, wlen, NULL, 0, NULL, NULL);
+ ascii_string = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char));
+ if (!ascii_string)
+ return;
+
+ WideCharToMultiByte(GetConsoleOutputCP(), 0, str, wlen, ascii_string, len, NULL, NULL);
+ WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), ascii_string, len, &count, FALSE);
+ HeapFree(GetProcessHeap(), 0, ascii_string);
+ }
}
static void WINEPROG_formatstring(const WCHAR *fmt, __ms_va_list va_args)
--
1.9.1
More information about the wine-patches
mailing list