Author: gadamopoulos
Date: Sat Apr 30 14:05:10 2016
New Revision: 71213
URL:
http://svn.reactos.org/svn/reactos?rev=71213&view=rev
Log:
[SHELL32]
- Add an overload of SHSetStrRet which loads strings by default from shell32.
- Remove some dead code fomr CDrivesFolder.
Modified:
trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp
trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp
trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.h
trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp
trunk/reactos/dll/win32/shell32/folders/CNetFolder.cpp
trunk/reactos/dll/win32/shell32/folders/CPrinterFolder.cpp
trunk/reactos/dll/win32/shell32/folders/CRecycleBin.cpp
trunk/reactos/dll/win32/shell32/shfldr.h
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] Sat Apr 30
14:05:10 2016
@@ -889,10 +889,7 @@
{
psd->fmt = DesktopSFHeader[iColumn].fmt;
psd->cxChar = DesktopSFHeader[iColumn].cxChar;
- psd->str.uType = STRRET_CSTR;
- LoadStringA (shell32_hInstance, DesktopSFHeader[iColumn].colnameid,
- psd->str.cStr, MAX_PATH);
- return S_OK;
+ return SHSetStrRet(&psd->str, DesktopSFHeader[iColumn].colnameid);
}
else if (_ILIsSpecialFolder(pidl))
{
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] Sat Apr 30
14:05:10 2016
@@ -164,7 +164,6 @@
CDrivesFolder::CDrivesFolder()
{
pidlRoot = NULL;
- sName = NULL;
}
CDrivesFolder::~CDrivesFolder()
@@ -175,26 +174,10 @@
HRESULT WINAPI CDrivesFolder::FinalConstruct()
{
- DWORD dwSize;
- WCHAR szName[MAX_PATH];
- WCHAR wszMyCompKey[256];
- INT i;
-
pidlRoot = _ILCreateMyComputer(); /* my qualified pidl */
if (pidlRoot == NULL)
return E_OUTOFMEMORY;
- i = swprintf(wszMyCompKey,
L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\");
- StringFromGUID2(CLSID_MyComputer, wszMyCompKey + i, sizeof(wszMyCompKey) /
sizeof(wszMyCompKey[0]) - i);
- dwSize = sizeof(szName);
- if (RegGetValueW(HKEY_CURRENT_USER, wszMyCompKey,
- NULL, RRF_RT_REG_SZ, NULL, szName, &dwSize) == ERROR_SUCCESS)
- {
- sName = (LPWSTR)SHAlloc((wcslen(szName) + 1) * sizeof(WCHAR));
- if (sName)
- wcscpy(sName, szName);
- TRACE("sName %s\n", debugstr_w(sName));
- }
return S_OK;
}
@@ -696,10 +679,7 @@
{
psd->fmt = MyComputerSFHeader[iColumn].fmt;
psd->cxChar = MyComputerSFHeader[iColumn].cxChar;
- psd->str.uType = STRRET_CSTR;
- LoadStringA(shell32_hInstance, MyComputerSFHeader[iColumn].colnameid,
- psd->str.cStr, MAX_PATH);
- return S_OK;
+ return SHSetStrRet(&psd->str, MyComputerSFHeader[iColumn].colnameid);
}
else if (_ILIsSpecialFolder(pidl))
{
Modified: trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.h [iso-8859-1] Sat Apr 30
14:05:10 2016
@@ -32,7 +32,6 @@
private:
/* both paths are parsible from the desktop */
LPITEMIDLIST pidlRoot; /* absolute pidl */
- LPWSTR sName;
public:
CDrivesFolder();
~CDrivesFolder();
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] Sat Apr 30 14:05:10
2016
@@ -813,10 +813,7 @@
/* the header titles */
psd->fmt = GenericSFHeader[iColumn].fmt;
psd->cxChar = GenericSFHeader[iColumn].cxChar;
- psd->str.uType = STRRET_CSTR;
- LoadStringA(shell32_hInstance, GenericSFHeader[iColumn].colnameid,
- psd->str.cStr, MAX_PATH);
- return S_OK;
+ return SHSetStrRet(&psd->str, GenericSFHeader[iColumn].colnameid);
}
else
{
Modified: trunk/reactos/dll/win32/shell32/folders/CNetFolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CNetFolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CNetFolder.cpp [iso-8859-1] Sat Apr 30
14:05:10 2016
@@ -464,43 +464,14 @@
*/
HRESULT WINAPI CNetFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET
strRet)
{
- LPWSTR pszName;
-
- TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", this, pidl, dwFlags, strRet);
- pdump (pidl);
-
if (!strRet)
return E_INVALIDARG;
if (!pidl->mkid.cb)
- {
- pszName = (LPWSTR)CoTaskMemAlloc(MAX_PATH * sizeof(WCHAR));
- if (!pszName)
- return E_OUTOFMEMORY;
-
- if (LoadStringW(shell32_hInstance, IDS_NETWORKPLACE, pszName, MAX_PATH))
- {
- pszName[MAX_PATH-1] = L'\0';
- strRet->uType = STRRET_WSTR;
- strRet->pOleStr = pszName;
- return S_OK;
- }
- CoTaskMemFree(pszName);
- return E_FAIL;
- }
+ return SHSetStrRet(strRet, IDS_NETWORKPLACE);
#ifdef HACKY_UNC_PATHS
else
- {
- LPCWSTR pstr = (LPCWSTR)pidl->mkid.abID;
- pszName = (LPWSTR)CoTaskMemAlloc(MAX_PATH * sizeof(WCHAR));
- if (!pszName)
- return E_OUTOFMEMORY;
-
- wcscpy(pszName, pstr);
- strRet->pOleStr = pszName;
- strRet->uType = STRRET_WSTR;
- return S_OK;
- }
+ return SHSetStrRet(strRet, (LPCWSTR)pidl->mkid.abID);
#endif
return E_NOTIMPL;
}
@@ -568,7 +539,6 @@
HRESULT WINAPI CNetFolder::GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS
*psd)
{
WCHAR buffer[MAX_PATH] = {0};
- HRESULT hr = E_FAIL;
if (iColumn >= NETWORKPLACESSHELLVIEWCOLUMNS)
return E_FAIL;
@@ -576,13 +546,7 @@
psd->fmt = NetworkPlacesSFHeader[iColumn].fmt;
psd->cxChar = NetworkPlacesSFHeader[iColumn].cxChar;
if (pidl == NULL)
- {
- psd->str.uType = STRRET_WSTR;
- if (LoadStringW(shell32_hInstance, NetworkPlacesSFHeader[iColumn].colnameid,
buffer, _countof(buffer)))
- hr = SHStrDupW(buffer, &psd->str.pOleStr);
-
- return hr;
- }
+ return SHSetStrRet(&psd->str, NetworkPlacesSFHeader[iColumn].colnameid);
if (iColumn == COLUMN_NAME)
return GetDisplayNameOf(pidl, SHGDN_NORMAL, &psd->str);
Modified: trunk/reactos/dll/win32/shell32/folders/CPrinterFolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CPrinterFolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CPrinterFolder.cpp [iso-8859-1] Sat Apr 30
14:05:10 2016
@@ -492,7 +492,6 @@
*/
HRESULT WINAPI CPrinterFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags,
LPSTRRET strRet)
{
- LPWSTR pszName;
PIDLPrinterStruct * p;
TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", this, pidl, dwFlags, strRet);
@@ -505,21 +504,7 @@
}
if (!pidl->mkid.cb)
- {
- pszName = (LPWSTR)CoTaskMemAlloc(MAX_PATH * sizeof(WCHAR));
- if (!pszName)
- return E_OUTOFMEMORY;
-
- if (LoadStringW(shell32_hInstance, IDS_PRINTERS, pszName, MAX_PATH))
- {
- pszName[MAX_PATH-1] = L'\0';
- strRet->uType = STRRET_WSTR;
- strRet->pOleStr = pszName;
- return S_OK;
- }
- CoTaskMemFree(pszName);
- return E_FAIL;
- }
+ return SHSetStrRet(strRet, IDS_PRINTERS);
p = _ILGetPrinterStruct(pidl);
if (!p)
@@ -527,14 +512,8 @@
WARN("no printer struct\n");
return E_INVALIDARG;
}
- strRet->pOleStr = (LPWSTR)SHAlloc(p->offsServer * sizeof(WCHAR));
- if (!strRet->pOleStr)
- return E_OUTOFMEMORY;
-
- memcpy((LPVOID)strRet->pOleStr, (LPVOID)p->szName, p->offsServer *
sizeof(WCHAR));
- TRACE("ret %s\n", debugstr_w(strRet->pOleStr));
-
- return S_OK;
+
+ return SHSetStrRet(strRet, p->szName);
}
/**************************************************************************
@@ -599,7 +578,6 @@
HRESULT WINAPI CPrinterFolder::GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn,
SHELLDETAILS *psd)
{
WCHAR buffer[MAX_PATH] = {0};
- HRESULT hr = E_FAIL;
TRACE("(%p)->(%p %i %p): stub\n", this, pidl, iColumn, psd);
@@ -609,19 +587,10 @@
psd->fmt = PrinterSFHeader[iColumn].fmt;
psd->cxChar = PrinterSFHeader[iColumn].cxChar;
if (pidl == NULL)
- {
- psd->str.uType = STRRET_WSTR;
- if (LoadStringW(shell32_hInstance, PrinterSFHeader[iColumn].colnameid, buffer,
MAX_PATH))
- hr = SHStrDupW(buffer, &psd->str.pOleStr);
-
- return hr;
- }
+ return SHSetStrRet(&psd->str, PrinterSFHeader[iColumn].colnameid);
if (iColumn == COLUMN_NAME)
- {
- psd->str.uType = STRRET_WSTR;
return GetDisplayNameOf(pidl, SHGDN_NORMAL, &psd->str);
- }
psd->str.uType = STRRET_CSTR;
psd->str.cStr[0] = '\0';
Modified: trunk/reactos/dll/win32/shell32/folders/CRecycleBin.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CRecycleBin.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CRecycleBin.cpp [iso-8859-1] Sat Apr 30
14:05:10 2016
@@ -740,11 +740,7 @@
pDetails->fmt = RecycleBinColumns[iColumn].fmt;
pDetails->cxChar = RecycleBinColumns[iColumn].cxChars;
if (pidl == NULL)
- {
- pDetails->str.uType = STRRET_WSTR;
- LoadStringW(shell32_hInstance, RecycleBinColumns[iColumn].column_name_id, buffer,
MAX_PATH);
- return SHStrDupW(buffer, &pDetails->str.pOleStr);
- }
+ return SHSetStrRet(&pDetails->str,
RecycleBinColumns[iColumn].column_name_id);
if (iColumn == COLUMN_NAME)
return GetDisplayNameOf(pidl, SHGDN_NORMAL, &pDetails->str);
@@ -780,15 +776,12 @@
if (LoadStringW(shell32_hInstance, IDS_SHV_COLUMN1,
&szTypeName[Length], (sizeof(szTypeName) / sizeof(WCHAR)) - Length))
szTypeName[(sizeof(szTypeName)/sizeof(WCHAR))-1] = L'\0';
}
- pDetails->str.uType = STRRET_WSTR;
- return SHStrDupW(szTypeName, &pDetails->str.pOleStr);
- break;
+ return SHSetStrRet(&pDetails->str, szTypeName);
default:
return E_FAIL;
}
- pDetails->str.uType = STRRET_WSTR;
- return SHStrDupW(buffer, &pDetails->str.pOleStr);
+ return SHSetStrRet(&pDetails->str, buffer);
}
HRESULT WINAPI CRecycleBin::MapColumnToSCID(UINT iColumn, SHCOLUMNID *pscid)
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] Sat Apr 30 14:05:10 2016
@@ -104,4 +104,13 @@
void SHELL_FS_ProcessDisplayFilename(LPWSTR szPath, DWORD dwFlags);
BOOL SHELL_FS_HideExtension(LPWSTR pwszPath);
+#ifdef __cplusplus
+
+HRESULT inline SHSetStrRet(LPSTRRET pStrRet, DWORD resId)
+{
+ return SHSetStrRet(pStrRet, shell32_hInstance, resId);
+}
+
+#endif
+
#endif /* _SHFLDR_H_ */