shell32: Implement SHCreateItemFromIDList.

This commit is contained in:
David Hedberg 2010-07-22 20:17:04 +02:00 committed by Alexandre Julliard
parent 5b0b56fac4
commit 222d2142ef
4 changed files with 78 additions and 0 deletions

View File

@ -330,6 +330,7 @@
@ stub SHChangeNotifySuspendResume
@ stdcall SHCreateDirectoryExA(long str ptr)
@ stdcall SHCreateDirectoryExW(long wstr ptr)
@ stdcall SHCreateItemFromIDList(ptr ptr ptr)
@ stdcall SHCreateItemFromParsingName(wstr ptr ptr ptr)
@ stub SHCreateProcessAsUserW
@ stdcall SHCreateShellItem(ptr ptr ptr ptr)

View File

@ -419,3 +419,21 @@ HRESULT WINAPI SHCreateItemFromParsingName(PCWSTR pszPath,
}
return ret;
}
HRESULT WINAPI SHCreateItemFromIDList(PCIDLIST_ABSOLUTE pidl, REFIID riid, void **ppv)
{
ShellItem *psiimpl;
HRESULT ret;
if(!pidl)
return E_INVALIDARG;
ret = IShellItem_Constructor(NULL, riid, ppv);
if(SUCCEEDED(ret))
{
psiimpl = (ShellItem*)*ppv;
psiimpl->pidl = ILClone(pidl);
}
return ret;
}

View File

@ -53,6 +53,7 @@ static HRESULT (WINAPI *pStrRetToBufW)(STRRET*,LPCITEMIDLIST,LPWSTR,UINT);
static LPITEMIDLIST (WINAPI *pILFindLastID)(LPCITEMIDLIST);
static void (WINAPI *pILFree)(LPITEMIDLIST);
static BOOL (WINAPI *pILIsEqual)(LPCITEMIDLIST, LPCITEMIDLIST);
static HRESULT (WINAPI *pSHCreateItemFromIDList)(PCIDLIST_ABSOLUTE pidl, REFIID riid, void **ppv);
static HRESULT (WINAPI *pSHCreateItemFromParsingName)(PCWSTR,IBindCtx*,REFIID,void**);
static HRESULT (WINAPI *pSHCreateShellItem)(LPCITEMIDLIST,IShellFolder*,LPCITEMIDLIST,IShellItem**);
static LPITEMIDLIST (WINAPI *pILCombine)(LPCITEMIDLIST,LPCITEMIDLIST);
@ -70,6 +71,7 @@ static void init_function_pointers(void)
#define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hmod, #f))
MAKEFUNC(SHBindToParent);
MAKEFUNC(SHCreateItemFromIDList);
MAKEFUNC(SHCreateItemFromParsingName);
MAKEFUNC(SHCreateShellItem);
MAKEFUNC(SHGetFolderPathA);
@ -2079,6 +2081,62 @@ static void test_SHCreateShellItem(void)
else
win_skip("No SHCreateItemFromParsingName\n");
/* SHCreateItemFromIDList */
if(pSHCreateItemFromIDList)
{
if(0)
{
/* Crashes under win7 */
ret = pSHCreateItemFromIDList(NULL, &IID_IShellItem, NULL);
}
ret = pSHCreateItemFromIDList(NULL, &IID_IShellItem, (void**)&shellitem);
ok(ret == E_INVALIDARG, "SHCreateItemFromIDList returned %x\n", ret);
ret = pSHCreateItemFromIDList(pidl_cwd, &IID_IShellItem, (void**)&shellitem);
ok(ret == S_OK, "SHCreateItemFromIDList returned %x\n", ret);
if (SUCCEEDED(ret))
{
ret = IShellItem_QueryInterface(shellitem, &IID_IPersistIDList, (void**)&persistidl);
ok(ret == S_OK, "QueryInterface returned %x\n", ret);
if (SUCCEEDED(ret))
{
ret = IPersistIDList_GetIDList(persistidl, &pidl_test);
ok(ret == S_OK, "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(shellitem);
}
ret = pSHCreateItemFromIDList(pidl_testfile, &IID_IShellItem, (void**)&shellitem);
ok(ret == S_OK, "SHCreateItemFromIDList returned %x\n", ret);
if (SUCCEEDED(ret))
{
ret = IShellItem_QueryInterface(shellitem, &IID_IPersistIDList, (void**)&persistidl);
ok(ret == S_OK, "QueryInterface returned %x\n", ret);
if (SUCCEEDED(ret))
{
ret = IPersistIDList_GetIDList(persistidl, &pidl_test);
ok(ret == S_OK, "GetIDList returned %x\n", ret);
if (SUCCEEDED(ret))
{
ok(ILIsEqual(pidl_testfile, pidl_test), "id lists are not equal\n");
pILFree(pidl_test);
}
IPersistIDList_Release(persistidl);
}
IShellItem_Release(shellitem);
}
}
else
win_skip("No SHCreateItemFromIDList\n");
DeleteFileA(".\\testfile");
pILFree(pidl_abstestfile);
pILFree(pidl_testfile);

View File

@ -496,6 +496,7 @@ interface IShellItemArray : IUnknown
cpp_quote("HRESULT WINAPI SHGetNameFromIDList(PCIDLIST_ABSOLUTE pidl, SIGDN sigdnName, PWSTR *ppszName);")
cpp_quote("HRESULT WINAPI SHCreateItemFromParsingName(PCWSTR pszPath, IBindCtx *pbc, REFIID riid, void **ppv);")
cpp_quote("HRESULT WINAPI SHCreateItemFromIDList(PCIDLIST_ABSOLUTE pidl, REFIID riid, void **ppv);")
/*****************************************************************************
* IShellItemFilter interface