[PATCH 1/3] uninstaller: Output in Unicode with WriteConsole (partial fix for bug 28186)
Hugh McMaster
hugh.mcmaster at outlook.com
Mon May 25 00:56:04 CDT 2015
---
programs/uninstaller/main.c | 51 ++++++++++++++++++++++++++++++++-------------
1 file changed, 37 insertions(+), 14 deletions(-)
diff --git a/programs/uninstaller/main.c b/programs/uninstaller/main.c
index 6b16e5d..f2ab82d 100644
--- a/programs/uninstaller/main.c
+++ b/programs/uninstaller/main.c
@@ -60,30 +60,53 @@ static const WCHAR UninstallCommandlineW[] = {'U','n','i','n','s','t','a','l','l
static const WCHAR WindowsInstallerW[] = {'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
static const WCHAR SystemComponentW[] = {'S','y','s','t','e','m','C','o','m','p','o','n','e','n','t',0};
+static void WINEPROG_writeconsole(const WCHAR *str, int wlen)
+{
+ DWORD count, ret;
+
+ ret = WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), str, wlen, &count, NULL);
+ if (!ret)
+ WINE_WARN("uninstaller: WriteConsole() failed.\n");
+}
+
+static void WINEPROG_formatstring(const WCHAR *fmt, __ms_va_list va_args)
+{
+ WCHAR *str;
+ DWORD len;
+
+ SetLastError(NO_ERROR);
+ len = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
+ fmt, 0, 0, (WCHAR *)&str, 0, &va_args);
+ if (len == 0 && GetLastError() != NO_ERROR)
+ {
+ WINE_FIXME("Could not format string: le=%u, fmt=%s\n", GetLastError(), wine_dbgstr_w(fmt));
+ return;
+ }
+ WINEPROG_writeconsole(str, len);
+ LocalFree(str);
+}
+
+static void WINEPROG_output_array(const WCHAR *fmt, ...)
+{
+ __ms_va_list va_args;
+
+ __ms_va_start(va_args, fmt);
+ WINEPROG_formatstring(fmt, va_args);
+ __ms_va_end(va_args);
+}
+
/**
* Used to output program list when used with --list
*/
static void ListUninstallPrograms(void)
{
unsigned int i;
- int lenDescr, lenKey;
- char *descr;
- char *key;
+ WCHAR fmtW[] = {'%','1',' ','%','2','\n',0};
FetchUninstallInformation();
for (i=0; i < numentries; i++)
- {
- lenDescr = WideCharToMultiByte(CP_UNIXCP, 0, entries[i].descr, -1, NULL, 0, NULL, NULL);
- lenKey = WideCharToMultiByte(CP_UNIXCP, 0, entries[i].key, -1, NULL, 0, NULL, NULL);
- descr = HeapAlloc(GetProcessHeap(), 0, lenDescr);
- key = HeapAlloc(GetProcessHeap(), 0, lenKey);
- WideCharToMultiByte(CP_UNIXCP, 0, entries[i].descr, -1, descr, lenDescr, NULL, NULL);
- WideCharToMultiByte(CP_UNIXCP, 0, entries[i].key, -1, key, lenKey, NULL, NULL);
- printf("%s|||%s\n", key, descr);
- HeapFree(GetProcessHeap(), 0, descr);
- HeapFree(GetProcessHeap(), 0, key);
- }
+ WINEPROG_output_array(fmtW, entries[i].key, entries[i].descr);
}
--
1.9.1
More information about the wine-patches
mailing list