Commit aaafeb4c authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

shell32: Implement IShellDispatch2::ShellExecute.

parent 263b06ef
......@@ -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)
......
......@@ -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();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment