Author: gschneider
Date: Fri Apr 22 22:53:31 2011
New Revision: 51435
URL:
http://svn.reactos.org/svn/reactos?rev=51435&view=rev
Log:
[shell32] Pass an argument array to FormatMessage to insert the filename details into
error messages (instead of failing)
See issue #5977 for more details.
Modified:
trunk/reactos/dll/win32/shell32/shlexec.c
Modified: trunk/reactos/dll/win32/shell32/shlexec.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shlexec.…
==============================================================================
--- trunk/reactos/dll/win32/shell32/shlexec.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/shlexec.c [iso-8859-1] Fri Apr 22 22:53:31 2011
@@ -1426,15 +1426,22 @@
return retval;
}
-void do_error_dialog( UINT_PTR retval, HWND hwnd )
+void do_error_dialog( UINT_PTR retval, HWND hwnd, WCHAR* filename)
{
WCHAR msg[2048];
- int error_code=GetLastError();
+ DWORD error_code = GetLastError();
+ DWORD_PTR msgArguments[3] = { (DWORD_PTR)filename, 0, 0 };
if (retval == SE_ERR_NOASSOC)
LoadStringW(shell32_hInstance, IDS_SHLEXEC_NOASSOC, msg,
sizeof(msg)/sizeof(WCHAR));
else
- FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error_code, 0, msg,
sizeof(msg)/sizeof(WCHAR), NULL);
+ FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY,
+ NULL,
+ error_code,
+ LANG_USER_DEFAULT,
+ msg,
+ sizeof(msg)/sizeof(WCHAR),
+ (va_list*)msgArguments);
MessageBoxW(hwnd, msg, NULL, MB_ICONERROR);
}
@@ -1596,7 +1603,7 @@
Info.oaifInFlags = OAIF_ALLOW_REGISTRATION | OAIF_EXEC;
//if (SHOpenWithDialog(sei_tmp.hwnd, &Info) != S_OK)
- do_error_dialog(retval, sei_tmp.hwnd);
+ do_error_dialog(retval, sei_tmp.hwnd, wszApplicationName);
}
HeapFree(GetProcessHeap(), 0, wszApplicationName);
if (wszParameters != parametersBuffer)
@@ -1824,7 +1831,7 @@
Info.oaifInFlags = OAIF_ALLOW_REGISTRATION | OAIF_EXEC;
//if (SHOpenWithDialog(sei_tmp.hwnd, &Info) != S_OK)
- do_error_dialog(retval, sei_tmp.hwnd);
+ do_error_dialog(retval, sei_tmp.hwnd, wszApplicationName);
}
HeapFree(GetProcessHeap(), 0, wszApplicationName);