shell32: Implement IShellItem_GetParent.

This commit is contained in:
Vincent Povirk 2009-05-21 13:18:26 -05:00 committed by Alexandre Julliard
parent 5b95a43d5e
commit 9eed85f032
2 changed files with 55 additions and 4 deletions

View File

@ -105,6 +105,27 @@ static ULONG WINAPI ShellItem_Release(IShellItem *iface)
return ref;
}
static HRESULT ShellItem_get_parent_pidl(ShellItem *This, LPITEMIDLIST *parent_pidl)
{
*parent_pidl = ILClone(This->pidl);
if (*parent_pidl)
{
if (ILRemoveLastID(*parent_pidl))
return S_OK;
else
{
ILFree(*parent_pidl);
*parent_pidl = NULL;
return E_INVALIDARG;
}
}
else
{
*parent_pidl = NULL;
return E_OUTOFMEMORY;
}
}
static HRESULT WINAPI ShellItem_BindToHandler(IShellItem *iface, IBindCtx *pbc,
REFGUID rbhid, REFIID riid, void **ppvOut)
{
@ -117,11 +138,20 @@ static HRESULT WINAPI ShellItem_BindToHandler(IShellItem *iface, IBindCtx *pbc,
static HRESULT WINAPI ShellItem_GetParent(IShellItem *iface, IShellItem **ppsi)
{
FIXME("(%p,%p)\n", iface, ppsi);
ShellItem *This = (ShellItem*)iface;
LPITEMIDLIST parent_pidl;
HRESULT ret;
*ppsi = NULL;
TRACE("(%p,%p)\n", iface, ppsi);
return E_NOTIMPL;
ret = ShellItem_get_parent_pidl(This, &parent_pidl);
if (SUCCEEDED(ret))
{
ret = SHCreateShellItem(NULL, NULL, parent_pidl, ppsi);
ILFree(parent_pidl);
}
return ret;
}
static HRESULT WINAPI ShellItem_GetDisplayName(IShellItem *iface, SIGDN sigdnName,

View File

@ -1747,7 +1747,7 @@ cleanup:
static void test_SHCreateShellItem(void)
{
IShellItem *shellitem;
IShellItem *shellitem, *shellitem2;
IPersistIDList *persistidl;
LPITEMIDLIST pidl_cwd=NULL, pidl_testfile, pidl_abstestfile, pidl_test;
HRESULT ret;
@ -1830,6 +1830,27 @@ static void test_SHCreateShellItem(void)
}
IPersistIDList_Release(persistidl);
}
ret = IShellItem_GetParent(shellitem, &shellitem2);
ok(SUCCEEDED(ret), "GetParent returned %x\n", ret);
if (SUCCEEDED(ret))
{
ret = IShellItem_QueryInterface(shellitem2, &IID_IPersistIDList, (void**)&persistidl);
ok(SUCCEEDED(ret), "QueryInterface returned %x\n", ret);
if (SUCCEEDED(ret))
{
ret = IPersistIDList_GetIDList(persistidl, &pidl_test);
ok(SUCCEEDED(ret), "GetIDList returned %x\n", ret);
if (SUCCEEDED(ret))
{
ok(ILIsEqual(pidl_cwd, pidl_test), "id lists are not equal\n");
pILFree(pidl_test);
}
IPersistIDList_Release(persistidl);
}
IShellItem_Release(shellitem2);
}
IShellItem_Release(shellitem);
}