mirror of
https://github.com/reactos/reactos.git
synced 2024-06-28 17:01:28 +00:00
[SHELL32]
- lnk files are .. files so don't pretend that CDrivesFolder and CControlPanelFolder can contain lnk files. - Don't create a full pidl just to parse it right away (which is a costly operation) when an IShellLink is queried from a folder. - Fix a bug in CDesktopFolder::GetDisplayNameOf that was exposed by changes above. svn path=/trunk/; revision=71237
This commit is contained in:
parent
0beda486ca
commit
f03ca04852
|
@ -2231,33 +2231,25 @@ HRESULT WINAPI CShellLink::Drop(IDataObject *pDataObject,
|
|||
/**************************************************************************
|
||||
* IShellLink_ConstructFromFile
|
||||
*/
|
||||
HRESULT WINAPI IShellLink_ConstructFromFile(IUnknown *pUnkOuter, REFIID riid, LPCITEMIDLIST pidl, LPVOID *ppv)
|
||||
HRESULT WINAPI IShellLink_ConstructFromPath(WCHAR *path, REFIID riid, LPVOID *ppv)
|
||||
{
|
||||
CComPtr<IUnknown> psl;
|
||||
CComPtr<IPersistFile> ppf;
|
||||
HRESULT hr = CShellLink::_CreatorClass::CreateInstance(NULL, IID_PPV_ARG(IPersistFile, &ppf));
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
HRESULT hr = CShellLink::_CreatorClass::CreateInstance(NULL, riid, (void**)&psl);
|
||||
hr = ppf->Load(path, 0);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
CComPtr<IPersistFile> ppf;
|
||||
|
||||
*ppv = NULL;
|
||||
|
||||
hr = psl->QueryInterface(IID_PPV_ARG(IPersistFile, &ppf));
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
WCHAR path[MAX_PATH];
|
||||
|
||||
if (SHGetPathFromIDListW(pidl, path))
|
||||
hr = ppf->Load(path, 0);
|
||||
else
|
||||
hr = E_FAIL;
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
*ppv = psl.Detach();
|
||||
}
|
||||
}
|
||||
|
||||
return hr;
|
||||
return ppf->QueryInterface(riid, ppv);
|
||||
}
|
||||
|
||||
HRESULT WINAPI IShellLink_ConstructFromFile(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv)
|
||||
{
|
||||
WCHAR path[MAX_PATH];
|
||||
if (!ILGetDisplayNameExW(psf, pidl, path, 0))
|
||||
return E_FAIL;
|
||||
|
||||
return IShellLink_ConstructFromPath(path, riid, ppv);
|
||||
}
|
|
@ -472,7 +472,6 @@ HRESULT WINAPI CControlPanelFolder::GetAttributesOf(UINT cidl, PCUITEMID_CHILD_A
|
|||
HRESULT WINAPI CControlPanelFolder::GetUIObjectOf(HWND hwndOwner,
|
||||
UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
|
||||
{
|
||||
LPITEMIDLIST pidl;
|
||||
LPVOID pObj = NULL;
|
||||
HRESULT hr = E_INVALIDARG;
|
||||
|
||||
|
@ -502,12 +501,6 @@ HRESULT WINAPI CControlPanelFolder::GetUIObjectOf(HWND hwndOwner,
|
|||
hr = IDataObject_Constructor(hwndOwner, pidlRoot, apidl, cidl, (IDataObject **)&pObj);
|
||||
} else if ((IsEqualIID(riid, IID_IExtractIconA) || IsEqualIID(riid, IID_IExtractIconW)) && (cidl == 1)) {
|
||||
hr = CCPLExtractIcon_CreateInstance(this, apidl[0], riid, &pObj);
|
||||
|
||||
} else if ((IsEqualIID(riid, IID_IShellLinkW) || IsEqualIID(riid, IID_IShellLinkA))
|
||||
&& (cidl == 1)) {
|
||||
pidl = ILCombine(pidlRoot, apidl[0]);
|
||||
hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj);
|
||||
SHFree(pidl);
|
||||
} else {
|
||||
hr = E_NOINTERFACE;
|
||||
}
|
||||
|
|
|
@ -589,7 +589,6 @@ HRESULT WINAPI CDesktopFolder::GetUIObjectOf(
|
|||
UINT *prgfInOut,
|
||||
LPVOID *ppvOut)
|
||||
{
|
||||
LPITEMIDLIST pidl;
|
||||
LPVOID pObj = NULL;
|
||||
HRESULT hr = E_INVALIDARG;
|
||||
|
||||
|
@ -624,9 +623,7 @@ HRESULT WINAPI CDesktopFolder::GetUIObjectOf(
|
|||
else if ((IsEqualIID(riid, IID_IShellLinkW) ||
|
||||
IsEqualIID(riid, IID_IShellLinkA)) && (cidl == 1))
|
||||
{
|
||||
pidl = ILCombine (pidlRoot, apidl[0]);
|
||||
hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj);
|
||||
SHFree (pidl);
|
||||
hr = IShellLink_ConstructFromFile(this, apidl[0], riid, &pObj);
|
||||
}
|
||||
else
|
||||
hr = E_NOINTERFACE;
|
||||
|
@ -682,7 +679,7 @@ HRESULT WINAPI CDesktopFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFl
|
|||
int cLen = 0;
|
||||
|
||||
/* file system folder or file rooted at the desktop */
|
||||
if ((GET_SHGDN_FOR(dwFlags) == SHGDN_FORPARSING) &&
|
||||
if ((GET_SHGDN_FOR(dwFlags) & SHGDN_FORPARSING) &&
|
||||
(GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER))
|
||||
{
|
||||
lstrcpynW(pszPath, sPathTarget, MAX_PATH - 1);
|
||||
|
@ -697,7 +694,7 @@ HRESULT WINAPI CDesktopFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFl
|
|||
if (GetFileAttributes(pszPath) == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
/* file system folder or file rooted at the AllUsers desktop */
|
||||
if ((GET_SHGDN_FOR(dwFlags) == SHGDN_FORPARSING) &&
|
||||
if ((GET_SHGDN_FOR(dwFlags) & SHGDN_FORPARSING) &&
|
||||
(GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER))
|
||||
{
|
||||
SHGetSpecialFolderPathW(0, pszPath, CSIDL_COMMON_DESKTOPDIRECTORY, FALSE);
|
||||
|
|
|
@ -435,7 +435,6 @@ HRESULT WINAPI CDrivesFolder::GetUIObjectOf(HWND hwndOwner,
|
|||
UINT cidl, PCUITEMID_CHILD_ARRAY apidl,
|
||||
REFIID riid, UINT *prgfInOut, LPVOID *ppvOut)
|
||||
{
|
||||
LPITEMIDLIST pidl;
|
||||
LPVOID pObj = NULL;
|
||||
HRESULT hr = E_INVALIDARG;
|
||||
|
||||
|
@ -466,13 +465,6 @@ HRESULT WINAPI CDrivesFolder::GetUIObjectOf(HWND hwndOwner,
|
|||
hr = this->QueryInterface(IID_PPV_ARG(IDropTarget, &pDt));
|
||||
pObj = pDt;
|
||||
}
|
||||
else if ((IsEqualIID(riid, IID_IShellLinkW) ||
|
||||
IsEqualIID(riid, IID_IShellLinkA)) && (cidl == 1))
|
||||
{
|
||||
pidl = ILCombine (pidlRoot, apidl[0]);
|
||||
hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*) &pObj);
|
||||
SHFree (pidl);
|
||||
}
|
||||
else
|
||||
hr = E_NOINTERFACE;
|
||||
|
||||
|
|
|
@ -487,7 +487,6 @@ HRESULT WINAPI CFSFolder::GetUIObjectOf(HWND hwndOwner,
|
|||
REFIID riid, UINT * prgfInOut,
|
||||
LPVOID * ppvOut)
|
||||
{
|
||||
LPITEMIDLIST pidl;
|
||||
LPVOID pObj = NULL;
|
||||
HRESULT hr = E_INVALIDARG;
|
||||
|
||||
|
@ -532,9 +531,7 @@ HRESULT WINAPI CFSFolder::GetUIObjectOf(HWND hwndOwner,
|
|||
else if ((IsEqualIID(riid, IID_IShellLinkW) ||
|
||||
IsEqualIID(riid, IID_IShellLinkA)) && (cidl == 1))
|
||||
{
|
||||
pidl = ILCombine (pidlRoot, apidl[0]);
|
||||
hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj);
|
||||
SHFree (pidl);
|
||||
hr = IShellLink_ConstructFromFile(this, apidl[0], riid, &pObj);
|
||||
}
|
||||
else
|
||||
hr = E_NOINTERFACE;
|
||||
|
@ -1426,7 +1423,7 @@ HRESULT WINAPI CFSFolder::_DoDrop(IDataObject *pDataObject,
|
|||
hr = E_FAIL;
|
||||
break;
|
||||
}
|
||||
hr = IShellLink_ConstructFromFile(NULL, IID_IPersistFile, ILCombine(pidl, apidl[i]), (LPVOID*)&ppf);
|
||||
hr = IShellLink_ConstructFromFile(this, apidl[i], IID_PPV_ARG(IPersistFile, &ppf));
|
||||
if (FAILED(hr)) {
|
||||
ERR("Error constructing link from file");
|
||||
break;
|
||||
|
|
|
@ -74,7 +74,8 @@ HRESULT WINAPI CDefView_Constructor(IShellFolder *pFolder, REFIID riid, LPVOID *
|
|||
HRESULT WINAPI CDefViewDual_Constructor(REFIID riid, LPVOID * ppvOut);
|
||||
HRESULT WINAPI CShell_Constructor(REFIID riid, LPVOID * ppvOut);
|
||||
|
||||
HRESULT WINAPI IShellLink_ConstructFromFile(IUnknown * pUnkOuter, REFIID riid, LPCITEMIDLIST pidl, LPVOID * ppv);
|
||||
HRESULT WINAPI IShellLink_ConstructFromPath(WCHAR *path, REFIID riid, LPVOID *ppv);
|
||||
HRESULT WINAPI IShellLink_ConstructFromFile(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv);
|
||||
HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV);
|
||||
HRESULT WINAPI CPanel_ExtractIconA(LPITEMIDLIST pidl, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) DECLSPEC_HIDDEN;
|
||||
HRESULT WINAPI CPanel_ExtractIconW(LPITEMIDLIST pidl, LPCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -823,8 +823,13 @@ void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
|
|||
ext = strrchr(doc_name, '.');
|
||||
if (!lstrcmpiA(ext, ".lnk"))
|
||||
{
|
||||
WCHAR doc_nameW[MAX_PATH];
|
||||
IShellLinkA* ShellLink;
|
||||
IShellLink_ConstructFromFile(NULL, &IID_IShellLinkA, (LPCITEMIDLIST)SHSimpleIDListFromPathA(doc_name), (LPVOID*)&ShellLink);
|
||||
int nLength = MultiByteToWideChar(CP_ACP, 0, doc_name, -1, doc_nameW, MAX_PATH);
|
||||
if (nLength == 0)
|
||||
return;
|
||||
|
||||
IShellLink_ConstructFromPath(doc_nameW, &IID_IShellLinkA, (LPVOID*)&ShellLink);
|
||||
IShellLinkA_GetPath(ShellLink, doc_name, MAX_PATH, NULL, 0);
|
||||
IShellLinkA_Release(ShellLink);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue