shell32: Cleanup IShellItem creation calls.
This commit is contained in:
parent
e9d010ef62
commit
17339f4f94
|
@ -548,7 +548,6 @@ HRESULT WINAPI IShellItem_Constructor(IUnknown *pUnkOuter, REFIID riid, void **p
|
||||||
HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent,
|
HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent,
|
||||||
IShellFolder *psfParent, LPCITEMIDLIST pidl, IShellItem **ppsi)
|
IShellFolder *psfParent, LPCITEMIDLIST pidl, IShellItem **ppsi)
|
||||||
{
|
{
|
||||||
ShellItem *This;
|
|
||||||
LPITEMIDLIST new_pidl;
|
LPITEMIDLIST new_pidl;
|
||||||
HRESULT ret;
|
HRESULT ret;
|
||||||
|
|
||||||
|
@ -597,16 +596,9 @@ HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent,
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = IShellItem_Constructor(NULL, &IID_IShellItem, (void**)&This);
|
ret = SHCreateItemFromIDList(new_pidl, &IID_IShellItem, (void**)ppsi);
|
||||||
if (This)
|
ILFree(new_pidl);
|
||||||
{
|
|
||||||
*ppsi = (IShellItem*)&This->IShellItem2_iface;
|
|
||||||
This->pidl = new_pidl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ILFree(new_pidl);
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,37 +613,34 @@ HRESULT WINAPI SHCreateItemFromParsingName(PCWSTR pszPath,
|
||||||
ret = SHParseDisplayName(pszPath, pbc, &pidl, 0, NULL);
|
ret = SHParseDisplayName(pszPath, pbc, &pidl, 0, NULL);
|
||||||
if(SUCCEEDED(ret))
|
if(SUCCEEDED(ret))
|
||||||
{
|
{
|
||||||
ShellItem *This;
|
ret = SHCreateItemFromIDList(pidl, riid, ppv);
|
||||||
ret = IShellItem_Constructor(NULL, riid, (void**)&This);
|
ILFree(pidl);
|
||||||
|
|
||||||
if(SUCCEEDED(ret))
|
|
||||||
{
|
|
||||||
This->pidl = pidl;
|
|
||||||
*ppv = (void*)This;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ILFree(pidl);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WINAPI SHCreateItemFromIDList(PCIDLIST_ABSOLUTE pidl, REFIID riid, void **ppv)
|
HRESULT WINAPI SHCreateItemFromIDList(PCIDLIST_ABSOLUTE pidl, REFIID riid, void **ppv)
|
||||||
{
|
{
|
||||||
ShellItem *psiimpl;
|
IPersistIDList *persist;
|
||||||
HRESULT ret;
|
HRESULT ret;
|
||||||
|
|
||||||
if(!pidl)
|
if(!pidl)
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
ret = IShellItem_Constructor(NULL, riid, ppv);
|
*ppv = NULL;
|
||||||
if(SUCCEEDED(ret))
|
ret = IShellItem_Constructor(NULL, &IID_IPersistIDList, (void**)&persist);
|
||||||
|
if(FAILED(ret))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ret = IPersistIDList_SetIDList(persist, pidl);
|
||||||
|
if(FAILED(ret))
|
||||||
{
|
{
|
||||||
psiimpl = (ShellItem*)*ppv;
|
IPersistIDList_Release(persist);
|
||||||
psiimpl->pidl = ILClone(pidl);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = IPersistIDList_QueryInterface(persist, riid, ppv);
|
||||||
|
IPersistIDList_Release(persist);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue