From 654822b9be19c2c641807bf5b436f2e394a15308 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Fri, 12 Sep 2008 00:54:14 +0000 Subject: [PATCH] Don't call FormatMessage() etc here. Call g_win32_error_message() instead 2008-09-12 Tor Lillqvist * gwin32appinfo.c (g_win32_app_info_launch): Don't call FormatMessage() etc here. Call g_win32_error_message() instead which already does all that. Besides, the code was broken as it called the default "A" version of FormatMessage() but still thought it produced a wide string. svn path=/trunk/; revision=7472 --- gio/ChangeLog | 8 ++++++++ gio/gwin32appinfo.c | 19 +++---------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/gio/ChangeLog b/gio/ChangeLog index 318df1b..4aa7b1a 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,11 @@ +2008-09-12 Tor Lillqvist + + * gwin32appinfo.c (g_win32_app_info_launch): Don't call + FormatMessage() etc here. Call g_win32_error_message() instead + which already does all that. Besides, the code was broken as it + called the default "A" version of FormatMessage() but still + thought it produced a wide string. + 2008-09-12 Michael Natterer * gfileinfo.c (g_file_info_get_content_type): remove dangling 's' diff --git a/gio/gwin32appinfo.c b/gio/gwin32appinfo.c index cec2533..0043258 100644 --- a/gio/gwin32appinfo.c +++ b/gio/gwin32appinfo.c @@ -293,25 +293,12 @@ g_win32_app_info_launch (GAppInfo *appinfo, exec_info.nShow = SW_SHOWNORMAL; exec_info.hkeyClass = class_key; - if (!ShellExecuteExW(&exec_info)) + if (!ShellExecuteExW (&exec_info)) { - DWORD last_error; - LPVOID message; - char *message_utf8; - - last_error = GetLastError (); - FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - last_error, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &message, - 0, NULL ); - - message_utf8 = g_utf16_to_utf8 (message, -1, NULL, NULL, NULL); + char *message_utf8 = g_win32_error_message (GetLastError ()); + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, _("Error launching application: %s"), message_utf8); g_free (message_utf8); - LocalFree (message); g_free (wfilename); RegCloseKey (class_key); -- 2.7.4