Module: wine Branch: master Commit: aaafeb4cec2c09630fac1ff1e75b448a23cb8421 URL: http://source.winehq.org/git/wine.git/?a=commit;h=aaafeb4cec2c09630fac1ff1e7...
Author: Andrew Eikum aeikum@codeweavers.com Date: Wed Oct 21 08:31:19 2015 -0500
shell32: Implement IShellDispatch2::ShellExecute.
Signed-off-by: Andrew Eikum aeikum@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/shell32/shelldispatch.c | 42 ++++++++++++++++++++++++++++++++++---- dlls/shell32/tests/shelldispatch.c | 41 +++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 4 deletions(-)
diff --git a/dlls/shell32/shelldispatch.c b/dlls/shell32/shelldispatch.c index f5eca28..6dece6d 100644 --- a/dlls/shell32/shelldispatch.c +++ b/dlls/shell32/shelldispatch.c @@ -1569,11 +1569,45 @@ static HRESULT WINAPI ShellDispatch_IsRestricted(IShellDispatch6 *iface, BSTR gr return E_NOTIMPL; }
-static HRESULT WINAPI ShellDispatch_ShellExecute(IShellDispatch6 *iface, BSTR file, VARIANT args, VARIANT dir, - VARIANT op, VARIANT show) +static HRESULT WINAPI ShellDispatch_ShellExecute(IShellDispatch6 *iface, + BSTR file, VARIANT v_args, VARIANT v_dir, VARIANT v_op, VARIANT v_show) { - FIXME("(%s): stub\n", debugstr_w(file)); - return E_NOTIMPL; + VARIANT args_str, dir_str, op_str, show_int; + WCHAR *args = NULL, *dir = NULL, *op = NULL; + INT show = 0; + HINSTANCE ret; + + TRACE("(%s, %s, %s, %s, %s)\n", debugstr_w(file), debugstr_variant(&v_args), + debugstr_variant(&v_dir), debugstr_variant(&v_op), debugstr_variant(&v_show)); + + VariantInit(&args_str); + VariantChangeType(&args_str, &v_args, 0, VT_BSTR); + if (V_VT(&args_str) == VT_BSTR) + args = V_BSTR(&args_str); + + VariantInit(&dir_str); + VariantChangeType(&dir_str, &v_dir, 0, VT_BSTR); + if (V_VT(&dir_str) == VT_BSTR) + dir = V_BSTR(&dir_str); + + VariantInit(&op_str); + VariantChangeType(&op_str, &v_op, 0, VT_BSTR); + if (V_VT(&op_str) == VT_BSTR) + op = V_BSTR(&op_str); + + VariantInit(&show_int); + VariantChangeType(&show_int, &v_show, 0, VT_I4); + if (V_VT(&show_int) == VT_I4) + show = V_I4(&show_int); + + ret = ShellExecuteW(NULL, op, file, args, dir, show); + + VariantClear(&args_str); + VariantClear(&dir_str); + VariantClear(&op_str); + VariantClear(&show_int); + + return (ULONG_PTR)ret > 32 ? S_OK : S_FALSE; }
static HRESULT WINAPI ShellDispatch_FindPrinter(IShellDispatch6 *iface, BSTR name, BSTR location, BSTR model) diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c index e4bda93..dfcbe6d 100644 --- a/dlls/shell32/tests/shelldispatch.c +++ b/dlls/shell32/tests/shelldispatch.c @@ -829,6 +829,46 @@ if (0) { /* crashes on winxp/win2k3 */ IShellDispatch_Release(sd); }
+static void test_ShellExecute(void) +{ + HRESULT hr; + IShellDispatch2 *sd; + BSTR name; + VARIANT args, dir, op, show; + + static const WCHAR regW[] = {'r','e','g',0}; + + hr = CoCreateInstance(&CLSID_Shell, NULL, CLSCTX_INPROC_SERVER, + &IID_IShellDispatch2, (void**)&sd); + if (hr != S_OK) + { + win_skip("IShellDispatch2 not supported\n"); + return; + } + + VariantInit(&args); + VariantInit(&dir); + VariantInit(&op); + VariantInit(&show); + + V_VT(&show) = VT_I4; + V_I4(&show) = 0; + + name = SysAllocString(regW); + + hr = IShellDispatch2_ShellExecute(sd, name, args, dir, op, show); + ok(hr == S_OK, "ShellExecute failed: %08x\n", hr); + + /* test invalid value for show */ + V_VT(&show) = VT_BSTR; + V_BSTR(&show) = name; + + hr = IShellDispatch2_ShellExecute(sd, name, args, dir, op, show); + ok(hr == S_OK, "ShellExecute failed: %08x\n", hr); + + SysFreeString(name); +} + START_TEST(shelldispatch) { HRESULT r; @@ -845,6 +885,7 @@ START_TEST(shelldispatch) test_ShellWindows(); test_ParseName(); test_Verbs(); + test_ShellExecute();
CoUninitialize(); }