[PATCH] shell32: Implement IShellDispatch2::ShellExecute

Andrew Eikum aeikum at codeweavers.com
Tue Oct 20 13:25:53 CDT 2015


Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
---
 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..8e481d2 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_str;
+    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(&v_args);
+    VariantChangeType(&args_str, &v_args, 0, VT_BSTR);
+    if (V_VT(&v_args) == VT_BSTR)
+        args = V_BSTR(&v_args);
+
+    VariantInit(&v_dir);
+    VariantChangeType(&dir_str, &v_dir, 0, VT_BSTR);
+    if (V_VT(&v_dir) == VT_BSTR)
+        dir = V_BSTR(&v_dir);
+
+    VariantInit(&v_op);
+    VariantChangeType(&op_str, &v_op, 0, VT_BSTR);
+    if (V_VT(&v_op) == VT_BSTR)
+        op = V_BSTR(&v_op);
+
+    VariantInit(&v_show);
+    VariantChangeType(&show_str, &v_show, 0, VT_I4);
+    if (V_VT(&v_show) == VT_I4)
+        show = V_I4(&v_show);
+
+    ret = ShellExecuteW(NULL, op, file, args, dir, show);
+
+    VariantClear(&v_args);
+    VariantClear(&v_dir);
+    VariantClear(&v_op);
+    VariantClear(&v_show);
+
+    return (UINT)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();
 }
-- 
2.6.1




More information about the wine-patches mailing list