Author: gadamopoulos
Date: Tue May 3 09:15:36 2016
New Revision: 71237
URL:
http://svn.reactos.org/svn/reactos?rev=71237&view=rev
Log:
[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.
Modified:
trunk/reactos/dll/win32/shell32/CShellLink.cpp
trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp
trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp
trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp
trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp
trunk/reactos/dll/win32/shell32/wine/shell32_main.h
trunk/reactos/dll/win32/shell32/wine/shellord.c
Modified: trunk/reactos/dll/win32/shell32/CShellLink.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/CShellLi…
==============================================================================
--- trunk/reactos/dll/win32/shell32/CShellLink.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/CShellLink.cpp [iso-8859-1] Tue May 3 09:15:36 2016
@@ -2231,33 +2231,25 @@
/**************************************************************************
* IShellLink_ConstructFromFile
*/
-HRESULT WINAPI IShellLink_ConstructFromFile(IUnknown *pUnkOuter, REFIID riid,
LPCITEMIDLIST pidl, LPVOID *ppv)
-{
- CComPtr<IUnknown> psl;
-
- HRESULT hr = CShellLink::_CreatorClass::CreateInstance(NULL, riid,
(void**)&psl);
-
- 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;
-}
+HRESULT WINAPI IShellLink_ConstructFromPath(WCHAR *path, REFIID riid, LPVOID *ppv)
+{
+ CComPtr<IPersistFile> ppf;
+ HRESULT hr = CShellLink::_CreatorClass::CreateInstance(NULL,
IID_PPV_ARG(IPersistFile, &ppf));
+ if (FAILED(hr))
+ return hr;
+
+ hr = ppf->Load(path, 0);
+ if (FAILED(hr))
+ 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);
+}
Modified: trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp [iso-8859-1]
(original)
+++ trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp [iso-8859-1] Tue May
3 09:15:36 2016
@@ -472,7 +472,6 @@
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 @@
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;
}
Modified: trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp [iso-8859-1] Tue May 3
09:15:36 2016
@@ -589,7 +589,6 @@
UINT *prgfInOut,
LPVOID *ppvOut)
{
- LPITEMIDLIST pidl;
LPVOID pObj = NULL;
HRESULT hr = E_INVALIDARG;
@@ -624,9 +623,7 @@
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 @@
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 @@
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);
Modified: trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp [iso-8859-1] Tue May 3
09:15:36 2016
@@ -435,7 +435,6 @@
UINT cidl, PCUITEMID_CHILD_ARRAY apidl,
REFIID riid, UINT *prgfInOut, LPVOID *ppvOut)
{
- LPITEMIDLIST pidl;
LPVOID pObj = NULL;
HRESULT hr = E_INVALIDARG;
@@ -465,13 +464,6 @@
IDropTarget * pDt = NULL;
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;
Modified: trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp [iso-8859-1] Tue May 3 09:15:36
2016
@@ -487,7 +487,6 @@
REFIID riid, UINT * prgfInOut,
LPVOID * ppvOut)
{
- LPITEMIDLIST pidl;
LPVOID pObj = NULL;
HRESULT hr = E_INVALIDARG;
@@ -532,9 +531,7 @@
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 @@
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;
Modified: trunk/reactos/dll/win32/shell32/wine/shell32_main.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/wine/she…
==============================================================================
--- trunk/reactos/dll/win32/shell32/wine/shell32_main.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/wine/shell32_main.h [iso-8859-1] Tue May 3 09:15:36
2016
@@ -74,7 +74,8 @@
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;
Modified: trunk/reactos/dll/win32/shell32/wine/shellord.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/wine/she…
==============================================================================
--- trunk/reactos/dll/win32/shell32/wine/shellord.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/wine/shellord.c [iso-8859-1] Tue May 3 09:15:36 2016
@@ -823,8 +823,13 @@
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);
}