Commit 6634b315 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

shell32: Support BYREF index in FolderItems::Item().

parent 824837ec
......@@ -1129,19 +1129,24 @@ static HRESULT WINAPI FolderItemsImpl_get_Parent(FolderItems3 *iface, IDispatch
return E_NOTIMPL;
}
static HRESULT WINAPI FolderItemsImpl_Item(FolderItems3 *iface, VARIANT index, FolderItem **item)
static HRESULT WINAPI FolderItemsImpl_Item(FolderItems3 *iface, VARIANT var, FolderItem **item)
{
FolderItemsImpl *This = impl_from_FolderItems(iface);
BSTR display_name = NULL;
VARIANT index;
HRESULT hr;
TRACE("(%p,%s,%p)\n", iface, debugstr_variant(&index), item);
TRACE("(%p,%s,%p)\n", iface, debugstr_variant(&var), item);
*item = NULL;
if (!shellfolder_exists(This->folder->path))
return S_FALSE;
VariantInit(&index);
if (FAILED(hr = VariantCopyInd(&index, &var)))
return hr;
switch (V_VT(&index))
{
case VT_I2:
......@@ -1163,8 +1168,9 @@ static HRESULT WINAPI FolderItemsImpl_Item(FolderItems3 *iface, VARIANT index, F
if (!V_BSTR(&index))
return S_FALSE;
if (FAILED(hr = IShellFolder2_ParseDisplayName(This->folder->folder, NULL, NULL, V_BSTR(&index),
NULL, &pidl, NULL)))
hr = IShellFolder2_ParseDisplayName(This->folder->folder, NULL, NULL, V_BSTR(&index), NULL, &pidl, NULL);
VariantClear(&index);
if (FAILED(hr))
return S_FALSE;
if (IShellFolder2_GetDisplayNameOf(This->folder->folder, pidl, SHGDN_FORPARSING, &strret) == S_OK)
......@@ -1176,7 +1182,8 @@ static HRESULT WINAPI FolderItemsImpl_Item(FolderItems3 *iface, VARIANT index, F
break;
default:
FIXME("Index type %d not handled.\n", V_VT(&index));
FIXME("Index type %#x not handled.\n", V_VT(&index));
VariantClear(&index);
/* fall through */
case VT_EMPTY:
return E_NOTIMPL;
......
......@@ -382,7 +382,7 @@ static void test_items(void)
FolderItems3 *items3 = NULL;
FolderItem *item = (FolderItem*)0xdeadbeef, *item2;
FolderItemVerbs *verbs = (FolderItemVerbs*)0xdeadbeef;
VARIANT var, int_index, str_index, str_index2;
VARIANT var, var2, int_index, str_index, str_index2;
IDispatch *disp, *disp2;
LONG count = -1;
IUnknown *unk;
......@@ -543,12 +543,14 @@ static void test_items(void)
ok(r == S_OK, "FolderItems::get_Count failed: %08x\n", r);
ok(count == ARRAY_SIZE(file_defs), "got %d files\n", count);
/* VT_EMPTY */
V_VT(&var) = VT_EMPTY;
item = (FolderItem*)0xdeadbeef;
r = FolderItems_Item(items, var, &item);
ok(r == E_NOTIMPL, "expected E_NOTIMPL, got %08x\n", r);
ok(!item, "item is not null\n");
/* VT_I2 */
V_VT(&var) = VT_I2;
V_I2(&var) = 0;
......@@ -571,6 +573,20 @@ static void test_items(void)
FolderItem_Release(item);
/* VT_VARIANT | VT_BYREF */
V_VT(&var2) = VT_I2;
V_I2(&var2) = 0;
V_VT(&var) = VT_BYREF | VT_VARIANT;
V_VARIANTREF(&var) = &var2;
item = NULL;
r = FolderItems_Item(items, var, &item);
ok(r == S_OK, "FolderItems::Item failed: %08x\n", r);
ok(!!item, "item is null\n");
FolderItem_Release(item);
/* VT_I4 */
V_VT(&var) = VT_I4;
V_I4(&var) = 0;
item = NULL;
......
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