Author: gadamopoulos
Date: Tue Sep 22 18:11:32 2015
New Revision: 69319
URL:
http://svn.reactos.org/svn/reactos?rev=69319&view=rev
Log:
[SHELL32]
- Add a helper HCR_GetClassName function to load the name of a reg folder to a STRRET
- Further simplify CAdminToolsFolder, CFontsFolder and CMyDocsFolder
Modified:
trunk/reactos/dll/win32/shell32/folders/CAdminToolsFolder.cpp
trunk/reactos/dll/win32/shell32/folders/CAdminToolsFolder.h
trunk/reactos/dll/win32/shell32/folders/CFontsFolder.cpp
trunk/reactos/dll/win32/shell32/folders/CFontsFolder.h
trunk/reactos/dll/win32/shell32/folders/CMyDocsFolder.cpp
trunk/reactos/dll/win32/shell32/folders/CMyDocsFolder.h
trunk/reactos/dll/win32/shell32/shfldr.h
trunk/reactos/dll/win32/shell32/shlfolder.cpp
Modified: trunk/reactos/dll/win32/shell32/folders/CAdminToolsFolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CAdminToolsFolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CAdminToolsFolder.cpp [iso-8859-1] Tue Sep 22
18:11:32 2015
@@ -23,43 +23,22 @@
WINE_DEFAULT_DEBUG_CHANNEL (shell);
-/*
-This folder should not exist. It is just a file system folder...
-*/
-
-/* List shortcuts of
- * CSIDL_COMMON_ADMINTOOLS
- * Note: CSIDL_ADMINTOOLS is ignored, tested with Window XP SP3+
- */
-
-/***********************************************************************
- * AdminTools folder implementation
- */
-
CAdminToolsFolder::CAdminToolsFolder()
{
m_pisfInner = NULL;
- m_pisf2Inner = NULL;
-
- szTarget = NULL;
}
CAdminToolsFolder::~CAdminToolsFolder()
{
- HeapFree(GetProcessHeap(), 0, szTarget);
m_pisfInner.Release();
- m_pisf2Inner.Release();
}
HRESULT WINAPI CAdminToolsFolder::FinalConstruct()
{
HRESULT hr;
CComPtr<IPersistFolder3> ppf3;
- hr = SHCoCreateInstance(NULL, &CLSID_ShellFSFolder, NULL,
IID_PPV_ARG(IShellFolder, &m_pisfInner));
- if (FAILED(hr))
- return hr;
-
- hr = m_pisfInner->QueryInterface(IID_PPV_ARG(IShellFolder2, &m_pisf2Inner));
+
+ hr = SHCoCreateInstance(NULL, &CLSID_ShellFSFolder, NULL,
IID_PPV_ARG(IShellFolder2, &m_pisfInner));
if (FAILED(hr))
return hr;
@@ -67,18 +46,16 @@
if (FAILED(hr))
return hr;
+ LPITEMIDLIST pidlRoot = _ILCreateAdminTools();
+
PERSIST_FOLDER_TARGET_INFO info;
ZeroMemory(&info, sizeof(PERSIST_FOLDER_TARGET_INFO));
info.csidl = CSIDL_COMMON_ADMINTOOLS;
- hr = ppf3->InitializeEx(NULL, _ILCreateAdminTools(), &info);
-
- szTarget = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
- if (szTarget == NULL)
- return E_OUTOFMEMORY;
- if (!SHGetSpecialFolderPathW(NULL, szTarget, CSIDL_COMMON_ADMINTOOLS, FALSE))
- return E_FAIL;
-
- return S_OK;
+ hr = ppf3->InitializeEx(NULL, pidlRoot, &info);
+
+ SHFree(pidlRoot);
+
+ return hr;
}
HRESULT WINAPI CAdminToolsFolder::ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLESTR
lpszDisplayName,
@@ -117,28 +94,22 @@
static const DWORD dwAdminToolsAttributes =
SFGAO_STORAGE | SFGAO_STORAGEANCESTOR | SFGAO_FILESYSANCESTOR |
SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER;
-
+
if(cidl)
- {
return m_pisfInner->GetAttributesOf(cidl, apidl, rgfInOut);
- }
- else
- {
- if (!rgfInOut)
- return E_INVALIDARG;
- if (cidl && !apidl)
- return E_INVALIDARG;
-
- if (*rgfInOut == 0)
- *rgfInOut = ~0;
-
- *rgfInOut &= dwAdminToolsAttributes;
-
- /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
- *rgfInOut &= ~SFGAO_VALIDATE;
-
- return S_OK;
- }
+
+ if (!rgfInOut || !apidl)
+ return E_INVALIDARG;
+
+ if (*rgfInOut == 0)
+ *rgfInOut = ~0;
+
+ *rgfInOut &= dwAdminToolsAttributes;
+
+ /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
+ *rgfInOut &= ~SFGAO_VALIDATE;
+
+ return S_OK;
}
HRESULT WINAPI CAdminToolsFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl,
PCUITEMID_CHILD_ARRAY apidl,
@@ -149,43 +120,25 @@
HRESULT WINAPI CAdminToolsFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags,
LPSTRRET strRet)
{
+ if (!strRet || !pidl)
+ return E_INVALIDARG;
+
+ /* If we got an fs item just forward to the fs folder */
if (!_ILIsSpecialFolder(pidl))
return m_pisfInner->GetDisplayNameOf(pidl, dwFlags, strRet);
- HRESULT hr = S_OK;
- LPWSTR pszPath;
-
- TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", this, pidl, dwFlags, strRet);
- pdump (pidl);
-
- if (!strRet)
- return E_INVALIDARG;
-
- pszPath = (LPWSTR)CoTaskMemAlloc((MAX_PATH + 1) * sizeof(WCHAR));
- if (!pszPath)
- return E_OUTOFMEMORY;
-
- ZeroMemory(pszPath, (MAX_PATH + 1) * sizeof(WCHAR));
-
- if (!pidl->mkid.cb)
+ /* The caller wants our path. Let fs folder handle it */
+ if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
+ (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING))
{
- if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
- (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING))
- wcscpy(pszPath, szTarget);
- else if (!HCR_GetClassNameW(CLSID_AdminFolderShortcut, pszPath, MAX_PATH))
- hr = E_FAIL;
+ /* Give an empty pidl to the fs folder to make it tell us its path */
+ if (pidl->mkid.cb)
+ pidl = ILGetNext(pidl);
+ return m_pisfInner->GetDisplayNameOf(pidl, dwFlags, strRet);
}
- if (SUCCEEDED(hr))
- {
- strRet->uType = STRRET_WSTR;
- strRet->pOleStr = pszPath;
- TRACE ("-- (%p)->(%s,0x%08x)\n", this,
debugstr_w(strRet->pOleStr), hr);
- }
- else
- CoTaskMemFree(pszPath);
-
- return hr;
+ /* Return the display name from the registry */
+ return HCR_GetClassName(CLSID_AdminFolderShortcut, strRet);
}
HRESULT WINAPI CAdminToolsFolder::SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, /*
simple pidl */
@@ -196,66 +149,58 @@
HRESULT WINAPI CAdminToolsFolder::GetDefaultSearchGUID(GUID *pguid)
{
- return m_pisf2Inner->GetDefaultSearchGUID(pguid);
+ return m_pisfInner->GetDefaultSearchGUID(pguid);
}
HRESULT WINAPI CAdminToolsFolder::EnumSearches(IEnumExtraSearch ** ppenum)
{
- return m_pisf2Inner->EnumSearches(ppenum);
+ return m_pisfInner->EnumSearches(ppenum);
}
HRESULT WINAPI CAdminToolsFolder::GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG
*pDisplay)
{
- return m_pisf2Inner->GetDefaultColumn(dwRes, pSort, pDisplay);
+ return m_pisfInner->GetDefaultColumn(dwRes, pSort, pDisplay);
}
HRESULT WINAPI CAdminToolsFolder::GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags)
{
- return m_pisf2Inner->GetDefaultColumnState(iColumn, pcsFlags);
+ return m_pisfInner->GetDefaultColumnState(iColumn, pcsFlags);
}
HRESULT WINAPI CAdminToolsFolder::GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID
*pscid, VARIANT *pv)
{
- return m_pisf2Inner->GetDetailsEx(pidl, pscid, pv);
+ return m_pisfInner->GetDetailsEx(pidl, pscid, pv);
}
HRESULT WINAPI CAdminToolsFolder::GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn,
SHELLDETAILS *psd)
{
- return m_pisf2Inner->GetDetailsOf(pidl, iColumn, psd);
+ return m_pisfInner->GetDetailsOf(pidl, iColumn, psd);
}
HRESULT WINAPI CAdminToolsFolder::MapColumnToSCID(UINT column, SHCOLUMNID *pscid)
{
- return m_pisf2Inner->MapColumnToSCID(column, pscid);
-}
-
-/************************************************************************
- * CAdminToolsFolder::GetClassID
- */
+ return m_pisfInner->MapColumnToSCID(column, pscid);
+}
+
HRESULT WINAPI CAdminToolsFolder::GetClassID(CLSID *lpClassId)
{
- TRACE ("(%p)\n", this);
+ if (!lpClassId)
+ return E_POINTER;
memcpy(lpClassId, &CLSID_AdminFolderShortcut, sizeof(CLSID));
return S_OK;
}
-/************************************************************************
- * CAdminToolsFolder::Initialize
- *
- */
HRESULT WINAPI CAdminToolsFolder::Initialize(LPCITEMIDLIST pidl)
{
return S_OK;
}
-/**************************************************************************
- * CAdminToolsFolder::GetCurFolder
- */
HRESULT WINAPI CAdminToolsFolder::GetCurFolder(LPITEMIDLIST *pidl)
{
- CComPtr<IPersistFolder2> ppf2;
- m_pisfInner->QueryInterface(IID_PPV_ARG(IPersistFolder2, &ppf2));
- return ppf2->GetCurFolder(pidl);
-}
+ if (!pidl)
+ return E_POINTER;
+ *pidl = _ILCreateAdminTools();
+ return S_OK;
+}
Modified: trunk/reactos/dll/win32/shell32/folders/CAdminToolsFolder.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CAdminToolsFolder.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CAdminToolsFolder.h [iso-8859-1] Tue Sep 22
18:11:32 2015
@@ -29,10 +29,8 @@
public IPersistFolder2
{
private:
- CComPtr<IShellFolder> m_pisfInner;
- CComPtr<IShellFolder2> m_pisf2Inner;
- LPWSTR szTarget;
- public:
+ CComPtr<IShellFolder2> m_pisfInner;
+ public:
CAdminToolsFolder();
~CAdminToolsFolder();
HRESULT WINAPI FinalConstruct();
Modified: trunk/reactos/dll/win32/shell32/folders/CFontsFolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CFontsFolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CFontsFolder.cpp [iso-8859-1] Tue Sep 22
18:11:32 2015
@@ -23,46 +23,20 @@
WINE_DEFAULT_DEBUG_CHANNEL (shell);
-/*
-This folder should not exist. It is just a file system folder... The \windows\fonts
-directory contains a hidden desktop.ini with a UIHandler entry that specifies a class
-that lives in fontext.dll. The UI handler creates a custom view for the folder, which
-is what we normally see. However, the folder is a perfectly normal CFSFolder.
-*/
-
-/***********************************************************************
-* IShellFolder implementation
-*/
-
CFontsFolder::CFontsFolder()
{
m_pisfInner = NULL;
- m_pisf2Inner = NULL;
-
- pidlRoot = NULL;
- apidl = NULL;
}
CFontsFolder::~CFontsFolder()
{
- TRACE("-- destroying IShellFolder(%p)\n", this);
- SHFree(pidlRoot);
-}
-
-static LPITEMIDLIST _ILCreateFont(void)
-{
- return _ILCreateGuid(PT_GUID, CLSID_FontsFolderShortcut);
}
HRESULT WINAPI CFontsFolder::FinalConstruct()
{
HRESULT hr;
CComPtr<IPersistFolder3> ppf3;
- hr = SHCoCreateInstance(NULL, &CLSID_ShellFSFolder, NULL,
IID_PPV_ARG(IShellFolder, &m_pisfInner));
- if (FAILED(hr))
- return hr;
-
- hr = m_pisfInner->QueryInterface(IID_PPV_ARG(IShellFolder2, &m_pisf2Inner));
+ hr = SHCoCreateInstance(NULL, &CLSID_ShellFSFolder, NULL,
IID_PPV_ARG(IShellFolder2, &m_pisfInner));
if (FAILED(hr))
return hr;
@@ -70,11 +44,17 @@
if (FAILED(hr))
return hr;
+ LPITEMIDLIST pidl = _ILCreateGuid(PT_GUID, CLSID_FontsFolderShortcut);
+ if (!pidl)
+ return E_OUTOFMEMORY;
+
PERSIST_FOLDER_TARGET_INFO info;
ZeroMemory(&info, sizeof(PERSIST_FOLDER_TARGET_INFO));
info.csidl = CSIDL_FONTS;
- hr = ppf3->InitializeEx(NULL, _ILCreateFont(), &info);
-
+ hr = ppf3->InitializeEx(NULL, pidl, &info);
+
+ ILFree(pidl);
+
return hr;
}
@@ -114,28 +94,22 @@
static const DWORD dwFontsAttributes =
SFGAO_STORAGE | SFGAO_STORAGEANCESTOR | SFGAO_FILESYSANCESTOR |
SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER;
-
+
if(cidl)
- {
return m_pisfInner->GetAttributesOf(cidl, apidl, rgfInOut);
- }
- else
- {
- if (!rgfInOut)
- return E_INVALIDARG;
- if (cidl && !apidl)
- return E_INVALIDARG;
-
- if (*rgfInOut == 0)
- *rgfInOut = ~0;
-
- *rgfInOut &= dwFontsAttributes;
-
- /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
- *rgfInOut &= ~SFGAO_VALIDATE;
-
- return S_OK;
- }
+
+ if (!rgfInOut || !apidl)
+ return E_INVALIDARG;
+
+ if (*rgfInOut == 0)
+ *rgfInOut = ~0;
+
+ *rgfInOut &= dwFontsAttributes;
+
+ /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
+ *rgfInOut &= ~SFGAO_VALIDATE;
+
+ return S_OK;
}
HRESULT WINAPI CFontsFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl,
PCUITEMID_CHILD_ARRAY apidl,
@@ -146,39 +120,26 @@
HRESULT WINAPI CFontsFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags,
LPSTRRET strRet)
{
+ if (!strRet || !pidl)
+ return E_INVALIDARG;
+
+ /* If we got an fs item just forward to the fs folder */
if (!_ILIsSpecialFolder(pidl))
return m_pisfInner->GetDisplayNameOf(pidl, dwFlags, strRet);
- TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", this, pidl, dwFlags, strRet);
- pdump (pidl);
-
- if (!strRet)
- return E_INVALIDARG;
-
-if (!pidl->mkid.cb)
+ /* The caller wants our path. Let fs folder handle it */
+ if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
+ (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING))
{
- WCHAR wszPath[MAX_PATH];
-
- if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
- (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING))
- {
- if (!SHGetSpecialFolderPathW(NULL, wszPath, CSIDL_FONTS, FALSE))
- return E_FAIL;
- }
- else if (!HCR_GetClassNameW(CLSID_FontsFolderShortcut, wszPath, MAX_PATH))
- return E_FAIL;
-
- strRet->pOleStr = (LPWSTR)CoTaskMemAlloc((wcslen(wszPath) + 1) *
sizeof(WCHAR));
- if (!strRet->pOleStr)
- return E_OUTOFMEMORY;
-
- wcscpy(strRet->pOleStr, wszPath);
- strRet->uType = STRRET_WSTR;
-
- return S_OK;
+ /* Give an empty pidl to the fs folder to tell us its path */
+ if (pidl->mkid.cb)
+ pidl = ILGetNext(pidl);
+
+ return m_pisfInner->GetDisplayNameOf(pidl, dwFlags, strRet);
}
- else
- return E_INVALIDARG;
+
+ /* Return the display name from the registry */
+ return HCR_GetClassName(CLSID_FontsFolderShortcut, strRet);
}
HRESULT WINAPI CFontsFolder::SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, /* simple
pidl */
@@ -189,46 +150,41 @@
HRESULT WINAPI CFontsFolder::GetDefaultSearchGUID(GUID *pguid)
{
- return m_pisf2Inner->GetDefaultSearchGUID(pguid);
+ return m_pisfInner->GetDefaultSearchGUID(pguid);
}
HRESULT WINAPI CFontsFolder::EnumSearches(IEnumExtraSearch ** ppenum)
{
- return m_pisf2Inner->EnumSearches(ppenum);
+ return m_pisfInner->EnumSearches(ppenum);
}
HRESULT WINAPI CFontsFolder::GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG
*pDisplay)
{
- return m_pisf2Inner->GetDefaultColumn(dwRes, pSort, pDisplay);
+ return m_pisfInner->GetDefaultColumn(dwRes, pSort, pDisplay);
}
HRESULT WINAPI CFontsFolder::GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags)
{
- return m_pisf2Inner->GetDefaultColumnState(iColumn, pcsFlags);
+ return m_pisfInner->GetDefaultColumnState(iColumn, pcsFlags);
}
HRESULT WINAPI CFontsFolder::GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid,
VARIANT *pv)
{
- return m_pisf2Inner->GetDetailsEx(pidl, pscid, pv);
+ return m_pisfInner->GetDetailsEx(pidl, pscid, pv);
}
HRESULT WINAPI CFontsFolder::GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn,
SHELLDETAILS *psd)
{
- return m_pisf2Inner->GetDetailsOf(pidl, iColumn, psd);
+ return m_pisfInner->GetDetailsOf(pidl, iColumn, psd);
}
HRESULT WINAPI CFontsFolder::MapColumnToSCID(UINT column, SHCOLUMNID *pscid)
{
- return m_pisf2Inner->MapColumnToSCID(column, pscid);
-}
-
-/************************************************************************
- * CFontsFolder::GetClassID
- */
+ return m_pisfInner->MapColumnToSCID(column, pscid);
+}
+
HRESULT WINAPI CFontsFolder::GetClassID(CLSID *lpClassId)
{
- TRACE ("(%p)\n", this);
-
if (!lpClassId)
return E_POINTER;
@@ -237,29 +193,17 @@
return S_OK;
}
-/************************************************************************
- * CFontsFolder::Initialize
- *
- * NOTES: it makes no sense to change the pidl
- */
HRESULT WINAPI CFontsFolder::Initialize(LPCITEMIDLIST pidl)
{
- TRACE ("(%p)->(%p)\n", this, pidl);
-
- return S_OK;
-}
-
-/**************************************************************************
- * CFontsFolder::GetCurFolder
- */
+ return S_OK;
+}
+
HRESULT WINAPI CFontsFolder::GetCurFolder(LPITEMIDLIST *pidl)
{
- TRACE ("(%p)->(%p)\n", this, pidl);
-
if (!pidl)
return E_POINTER;
- *pidl = ILClone(pidlRoot);
-
- return S_OK;
-}
+ *pidl = _ILCreateGuid(PT_GUID, CLSID_FontsFolderShortcut);
+
+ return S_OK;
+}
Modified: trunk/reactos/dll/win32/shell32/folders/CFontsFolder.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CFontsFolder.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CFontsFolder.h [iso-8859-1] Tue Sep 22
18:11:32 2015
@@ -29,12 +29,7 @@
public IPersistFolder2
{
private:
- CComPtr<IShellFolder> m_pisfInner;
- CComPtr<IShellFolder2> m_pisf2Inner;
-
- /* both paths are parsible from the desktop */
- LPITEMIDLIST pidlRoot; /* absolute pidl */
- LPCITEMIDLIST apidl; /* currently focused font item */
+ CComPtr<IShellFolder2> m_pisfInner;
public:
CFontsFolder();
~CFontsFolder();
Modified: trunk/reactos/dll/win32/shell32/folders/CMyDocsFolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CMyDocsFolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CMyDocsFolder.cpp [iso-8859-1] Tue Sep 22
18:11:32 2015
@@ -23,67 +23,38 @@
WINE_DEFAULT_DEBUG_CHANNEL (mydocs);
-/*
-CFileSysEnumX should not exist. CMyDocsFolder should aggregate a CFSFolder which always
-maps the contents of CSIDL_PERSONAL. Therefore, CMyDocsFolder::EnumObjects simply calls
-CFSFolder::EnumObjects.
-*/
-
-/***********************************************************************
-* MyDocumentsfolder implementation
-*/
-
CMyDocsFolder::CMyDocsFolder()
{
m_pisfInner = NULL;
- m_pisf2Inner = NULL;
- pidlRoot = NULL;
- sPathTarget = NULL;
}
CMyDocsFolder::~CMyDocsFolder()
{
- SHFree(pidlRoot);
- if (sPathTarget)
- HeapFree(GetProcessHeap(), 0, sPathTarget);
m_pisfInner.Release();
- m_pisf2Inner.Release();
}
HRESULT WINAPI CMyDocsFolder::FinalConstruct()
{
- WCHAR szMyPath[MAX_PATH];
-
- if (!SHGetSpecialFolderPathW(0, szMyPath, CSIDL_PERSONAL, TRUE))
- return E_UNEXPECTED;
-
- pidlRoot = _ILCreateMyDocuments(); /* my qualified pidl */
- sPathTarget = (LPWSTR)SHAlloc((wcslen(szMyPath) + 1) * sizeof(WCHAR));
- wcscpy(sPathTarget, szMyPath);
-
- WCHAR szPath[MAX_PATH];
- lstrcpynW(szPath, sPathTarget, MAX_PATH);
-
HRESULT hr;
CComPtr<IPersistFolder3> ppf3;
- hr = SHCoCreateInstance(NULL, &CLSID_ShellFSFolder, NULL,
IID_PPV_ARG(IShellFolder, &m_pisfInner));
- if (FAILED(hr))
- return hr;
-
- hr = m_pisfInner->QueryInterface(IID_PPV_ARG(IShellFolder2, &m_pisf2Inner));
+ hr = SHCoCreateInstance(NULL, &CLSID_ShellFSFolder, NULL,
IID_PPV_ARG(IShellFolder2, &m_pisfInner));
if (FAILED(hr))
return hr;
hr = m_pisfInner->QueryInterface(IID_PPV_ARG(IPersistFolder3, &ppf3));
if (FAILED(hr))
return hr;
+
+ LPITEMIDLIST pidlRoot = _ILCreateMyDocuments();
PERSIST_FOLDER_TARGET_INFO info;
ZeroMemory(&info, sizeof(PERSIST_FOLDER_TARGET_INFO));
info.csidl = CSIDL_PERSONAL;
hr = ppf3->InitializeEx(NULL, pidlRoot, &info);
+ SHFree(pidlRoot);
+
return hr;
}
@@ -125,26 +96,20 @@
SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER |
SFGAO_CANRENAME | SFGAO_CANDELETE;
if(cidl)
- {
return m_pisfInner->GetAttributesOf(cidl, apidl, rgfInOut);
- }
- else
- {
- if (!rgfInOut)
- return E_INVALIDARG;
- if (cidl && !apidl)
- return E_INVALIDARG;
-
- if (*rgfInOut == 0)
- *rgfInOut = ~0;
-
- *rgfInOut &= dwMyDocumentsAttributes;
-
- /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
- *rgfInOut &= ~SFGAO_VALIDATE;
-
- return S_OK;
- }
+
+ if (!rgfInOut || !apidl)
+ return E_INVALIDARG;
+
+ if (*rgfInOut == 0)
+ *rgfInOut = ~0;
+
+ *rgfInOut &= dwMyDocumentsAttributes;
+
+ /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
+ *rgfInOut &= ~SFGAO_VALIDATE;
+
+ return S_OK;
}
HRESULT WINAPI CMyDocsFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl,
PCUITEMID_CHILD_ARRAY apidl,
@@ -155,48 +120,25 @@
HRESULT WINAPI CMyDocsFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags,
LPSTRRET strRet)
{
+ if (!strRet || !pidl)
+ return E_INVALIDARG;
+
+ /* If we got an fs item just forward to the fs folder */
if (!_ILIsSpecialFolder(pidl))
return m_pisfInner->GetDisplayNameOf(pidl, dwFlags, strRet);
- HRESULT hr = S_OK;
- LPWSTR pszPath;
-
- TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", this, pidl, dwFlags, strRet);
- pdump (pidl);
-
- if (!strRet)
- return E_INVALIDARG;
-
- pszPath = (LPWSTR)CoTaskMemAlloc((MAX_PATH + 1) * sizeof(WCHAR));
- if (!pszPath)
- return E_OUTOFMEMORY;
-
- ZeroMemory(pszPath, (MAX_PATH + 1) * sizeof(WCHAR));
-
- if (_ILIsMyDocuments (pidl) || !pidl->mkid.cb)
+ /* The caller wants our path. Let fs folder handle it */
+ if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
+ (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING))
{
- if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
- (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING))
- wcscpy(pszPath, sPathTarget);
- else
- HCR_GetClassNameW(CLSID_MyDocuments, pszPath, MAX_PATH);
- TRACE("CP\n");
+ /* Give an empty pidl to the fs folder to make it tell us its path */
+ if (pidl->mkid.cb)
+ pidl = ILGetNext(pidl);
+ return m_pisfInner->GetDisplayNameOf(pidl, dwFlags, strRet);
}
- else
- {
- hr = E_INVALIDARG;
- }
-
- if (SUCCEEDED(hr))
- {
- strRet->uType = STRRET_WSTR;
- strRet->pOleStr = pszPath;
- }
- else
- CoTaskMemFree(pszPath);
-
- TRACE ("-- (%p)->(%s,0x%08x)\n", this, debugstr_w(strRet->pOleStr),
hr);
- return hr;
+
+ /* Return the display name from the registry */
+ return HCR_GetClassName(CLSID_MyDocuments, strRet);
}
HRESULT WINAPI CMyDocsFolder::SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, /*
simple pidl */
@@ -207,43 +149,41 @@
HRESULT WINAPI CMyDocsFolder::GetDefaultSearchGUID(GUID *pguid)
{
- return m_pisf2Inner->GetDefaultSearchGUID(pguid);
+ return m_pisfInner->GetDefaultSearchGUID(pguid);
}
HRESULT WINAPI CMyDocsFolder::EnumSearches(IEnumExtraSearch ** ppenum)
{
- return m_pisf2Inner->EnumSearches(ppenum);
+ return m_pisfInner->EnumSearches(ppenum);
}
HRESULT WINAPI CMyDocsFolder::GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG
*pDisplay)
{
- return m_pisf2Inner->GetDefaultColumn(dwRes, pSort, pDisplay);
+ return m_pisfInner->GetDefaultColumn(dwRes, pSort, pDisplay);
}
HRESULT WINAPI CMyDocsFolder::GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags)
{
- return m_pisf2Inner->GetDefaultColumnState(iColumn, pcsFlags);
+ return m_pisfInner->GetDefaultColumnState(iColumn, pcsFlags);
}
HRESULT WINAPI CMyDocsFolder::GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid,
VARIANT *pv)
{
- return m_pisf2Inner->GetDetailsEx(pidl, pscid, pv);
+ return m_pisfInner->GetDetailsEx(pidl, pscid, pv);
}
HRESULT WINAPI CMyDocsFolder::GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn,
SHELLDETAILS *psd)
{
- return m_pisf2Inner->GetDetailsOf(pidl, iColumn, psd);
+ return m_pisfInner->GetDetailsOf(pidl, iColumn, psd);
}
HRESULT WINAPI CMyDocsFolder::MapColumnToSCID(UINT column, SHCOLUMNID *pscid)
{
- return m_pisf2Inner->MapColumnToSCID(column, pscid);
+ return m_pisfInner->MapColumnToSCID(column, pscid);
}
HRESULT WINAPI CMyDocsFolder::GetClassID(CLSID *lpClassId)
{
- TRACE ("(%p)\n", this);
-
if (!lpClassId)
return E_POINTER;
@@ -254,16 +194,13 @@
HRESULT WINAPI CMyDocsFolder::Initialize(LPCITEMIDLIST pidl)
{
- TRACE ("(%p)->(%p)\n", this, pidl);
-
return S_OK;
}
HRESULT WINAPI CMyDocsFolder::GetCurFolder(LPITEMIDLIST *pidl)
{
- TRACE ("(%p)->(%p)\n", this, pidl);
-
- if (!pidl) return E_POINTER;
- *pidl = ILClone (pidlRoot);
- return S_OK;
-}
+ if (!pidl)
+ return E_POINTER;
+ *pidl = _ILCreateMyDocuments();
+ return S_OK;
+}
Modified: trunk/reactos/dll/win32/shell32/folders/CMyDocsFolder.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CMyDocsFolder.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CMyDocsFolder.h [iso-8859-1] Tue Sep 22
18:11:32 2015
@@ -29,12 +29,7 @@
public IPersistFolder2
{
private:
- CComPtr<IShellFolder> m_pisfInner;
- CComPtr<IShellFolder2> m_pisf2Inner;
-
- /* both paths are parsible from the MyDocuments */
- LPWSTR sPathTarget; /* complete path to target used for enumeration and
ChangeNotify */
- LPITEMIDLIST pidlRoot; /* absolute pidl */
+ CComPtr<IShellFolder2> m_pisfInner;
public:
CMyDocsFolder();
~CMyDocsFolder();
Modified: trunk/reactos/dll/win32/shell32/shfldr.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shfldr.h…
==============================================================================
--- trunk/reactos/dll/win32/shell32/shfldr.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/shfldr.h [iso-8859-1] Tue Sep 22 18:11:32 2015
@@ -39,6 +39,9 @@
LPCWSTR GetNextElementW (LPCWSTR pszNext, LPWSTR pszOut, DWORD dwOut);
HRESULT SHELL32_ParseNextElement (IShellFolder2 * psf, HWND hwndOwner, LPBC pbc,
LPITEMIDLIST * pidlInOut,
LPOLESTR szNext, DWORD * pEaten, DWORD * pdwAttributes);
+
+HRESULT HCR_GetClassName(REFIID riid, LPSTRRET strRet);
+
HRESULT SHELL32_GetDisplayNameOfChild (IShellFolder2 * psf, LPCITEMIDLIST pidl, DWORD
dwFlags, LPSTRRET strRet);
HRESULT SHELL32_BindToFS (LPCITEMIDLIST pidlRoot,
Modified: trunk/reactos/dll/win32/shell32/shlfolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shlfolde…
==============================================================================
--- trunk/reactos/dll/win32/shell32/shlfolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/shlfolder.cpp [iso-8859-1] Tue Sep 22 18:11:32 2015
@@ -374,6 +374,17 @@
ILFree (pidlFirst);
return hr;
+}
+
+HRESULT HCR_GetClassName(REFIID riid, LPSTRRET strRet)
+{
+ BOOL bRet;
+ WCHAR wstrName[MAX_PATH+1];
+ bRet = HCR_GetClassNameW(CLSID_MyDocuments, wstrName, MAX_PATH);
+ if (!bRet)
+ return E_FAIL;
+
+ return SHSetStrRet(strRet, wstrName);
}
HRESULT SHELL32_GetDisplayNameOfGUIDItem(IShellFolder2* psf, LPCWSTR pszFolderPath,
PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet)