Author: dquintana
Date: Wed Aug 26 17:31:42 2015
New Revision: 68828
URL:
http://svn.reactos.org/svn/reactos?rev=68828&view=rev
Log:
[SHELL32]
* Fix loading icon info from dekstop.ini. Also took the chance to remove some unnecessary
convolution. The old code tried to load the info, but didn't actually make use of the
returned string at all.
CORE-9002 #resolve #comment Icon loading should work now. Adding the default desktop.ini
files in the right folders will be a followup issue.
Modified:
trunk/reactos/dll/win32/shell32/folders.cpp
trunk/reactos/dll/win32/shell32/shfldr.h
trunk/reactos/dll/win32/shell32/shlfolder.cpp
Modified: trunk/reactos/dll/win32/shell32/folders.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders.…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders.cpp [iso-8859-1] Wed Aug 26 17:31:42 2015
@@ -27,64 +27,58 @@
static HRESULT getIconLocationForFolder(LPCITEMIDLIST pidl, UINT uFlags,
LPWSTR szIconFile, UINT cchMax, int *piIndex,
UINT *pwFlags)
{
- int icon_idx;
- bool cont=TRUE;
- WCHAR wszPath[MAX_PATH];
- WCHAR wszCLSIDValue[CHARS_IN_GUID];
static const WCHAR shellClassInfo[] = { '.', 'S', 'h',
'e', 'l', 'l', 'C', 'l', 'a', 's',
's', 'I', 'n', 'f', 'o', 0 };
static const WCHAR iconFile[] = { 'I', 'c', 'o', 'n',
'F', 'i', 'l', 'e', 0 };
static const WCHAR clsid[] = { 'C', 'L', 'S', 'I',
'D', 0 };
static const WCHAR clsid2[] = { 'C', 'L', 'S', 'I',
'D', '2', 0 };
static const WCHAR iconIndex[] = { 'I', 'c', 'o',
'n', 'I', 'n', 'd', 'e', 'x', 0 };
-
- /*
- Optimisation. GetCustomFolderAttribute has a critical lock on it, and isn't
fast.
- Test the water (i.e., see if the attribute exists) before questioning it three times
- when most folders don't use it at all.
- */
- WCHAR wszBigToe[3];
- if (!(uFlags & GIL_DEFAULTICON) &&
SHELL32_GetCustomFolderAttributes(pidl, shellClassInfo,
- wszBigToe, 3))
- {
- if (SHELL32_GetCustomFolderAttribute(pidl, shellClassInfo, iconFile,
- wszPath, MAX_PATH))
- {
- WCHAR wszIconIndex[10];
- SHELL32_GetCustomFolderAttribute(pidl, shellClassInfo, iconIndex,
- wszIconIndex, 10);
- *piIndex = _wtoi(wszIconIndex);
- cont=FALSE;
- }
- else if (SHELL32_GetCustomFolderAttribute(pidl, shellClassInfo, clsid,
- wszCLSIDValue, CHARS_IN_GUID) &&
+ static const WCHAR wszDesktopIni[] = {
'd','e','s','k','t','o','p','.','i','n','i',0
};
+ int icon_idx;
+ WCHAR wszFolderPath[MAX_PATH];
+
+ if (!SHGetPathFromIDListW(pidl, wszFolderPath))
+ return FALSE;
+
+ PathAppendW(wszFolderPath, wszDesktopIni);
+
+ if (!(uFlags & GIL_DEFAULTICON) && PathFileExistsW(wszFolderPath))
+ {
+ WCHAR wszPath[MAX_PATH];
+ WCHAR wszCLSIDValue[CHARS_IN_GUID];
+
+ if (GetPrivateProfileStringW(shellClassInfo, iconFile, NULL, wszPath, MAX_PATH,
wszFolderPath))
+ {
+ ExpandEnvironmentStringsW(wszPath, szIconFile, cchMax);
+
+ *piIndex = GetPrivateProfileIntW(shellClassInfo, iconIndex, 0,
wszFolderPath);
+ return S_OK;
+ }
+ else if (GetPrivateProfileStringW(shellClassInfo, clsid, NULL, wszCLSIDValue,
CHARS_IN_GUID, wszFolderPath) &&
HCR_GetIconW(wszCLSIDValue, szIconFile, NULL, cchMax, &icon_idx))
{
*piIndex = icon_idx;
- cont=FALSE;
- }
- else if (SHELL32_GetCustomFolderAttribute(pidl, shellClassInfo, clsid2,
- wszCLSIDValue, CHARS_IN_GUID) &&
+ return S_OK;
+ }
+ else if (GetPrivateProfileStringW(shellClassInfo, clsid2, NULL, wszCLSIDValue,
CHARS_IN_GUID, wszFolderPath) &&
HCR_GetIconW(wszCLSIDValue, szIconFile, NULL, cchMax, &icon_idx))
{
*piIndex = icon_idx;
- cont=FALSE;
- }
- }
- if (cont)
- {
- static const WCHAR folder[] = { 'F', 'o', 'l',
'd', 'e', 'r', 0 };
-
- if (!HCR_GetIconW(folder, szIconFile, NULL, cchMax, &icon_idx))
- {
- lstrcpynW(szIconFile, swShell32Name, cchMax);
- icon_idx = -IDI_SHELL_FOLDER;
- }
-
- if (uFlags & GIL_OPENICON)
- *piIndex = icon_idx < 0 ? icon_idx - 1 : icon_idx + 1;
- else
- *piIndex = icon_idx;
- }
+ return S_OK;
+ }
+ }
+
+ static const WCHAR folder[] = { 'F', 'o', 'l', 'd',
'e', 'r', 0 };
+
+ if (!HCR_GetIconW(folder, szIconFile, NULL, cchMax, &icon_idx))
+ {
+ lstrcpynW(szIconFile, swShell32Name, cchMax);
+ icon_idx = -IDI_SHELL_FOLDER;
+ }
+
+ if (uFlags & GIL_OPENICON)
+ *piIndex = icon_idx < 0 ? icon_idx - 1 : icon_idx + 1;
+ else
+ *piIndex = icon_idx;
return S_OK;
}
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] Wed Aug 26 17:31:42 2015
@@ -35,9 +35,6 @@
#define GET_SHGDN_FOR(dwFlags) ((DWORD)dwFlags & (DWORD)0x0000FF00)
#define GET_SHGDN_RELATION(dwFlags) ((DWORD)dwFlags & (DWORD)0x000000FF)
-
-BOOL SHELL32_GetCustomFolderAttribute (LPCITEMIDLIST pidl, LPCWSTR pwszHeading, LPCWSTR
pwszAttribute, LPWSTR pwszValue, DWORD cchValue);
-BOOL SHELL32_GetCustomFolderAttributes (LPCITEMIDLIST pidl, LPCWSTR pwszHeading, LPWSTR
pwszValue, DWORD cchValue);
LPCWSTR GetNextElementW (LPCWSTR pszNext, LPWSTR pszOut, DWORD dwOut);
HRESULT SHELL32_ParseNextElement (IShellFolder2 * psf, HWND hwndOwner, LPBC pbc,
LPITEMIDLIST * pidlInOut,
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] Wed Aug 26 17:31:42 2015
@@ -25,16 +25,13 @@
WINE_DEFAULT_DEBUG_CHANNEL(shell);
-static const WCHAR wszDotShellClassInfo[] = {
-
'.','S','h','e','l','l','C','l','a','s','s','I','n','f','o',0};
-
/***************************************************************************
- * SHELL32_GetCustomFolderAttribute (internal function)
+ * SHELL32_GetCustomFolderAttributeFromPath (internal function)
*
* Gets a value from the folder's desktop.ini file, if one exists.
*
* PARAMETERS
- * pidl [I] Folder containing the desktop.ini file.
+ * pwszFolderPath[I] Folder containing the desktop.ini file.
* pwszHeading [I] Heading in .ini file.
* pwszAttribute [I] Attribute in .ini file.
* pwszValue [O] Buffer to store value into.
@@ -58,54 +55,6 @@
return GetPrivateProfileStringW(pwszHeading, pwszAttribute, wszDefault,
pwszValue, cchValue, pwszFolderPath);
}
-
-BOOL SHELL32_GetCustomFolderAttribute(
- LPCITEMIDLIST pidl, LPCWSTR pwszHeading, LPCWSTR pwszAttribute,
- LPWSTR pwszValue, DWORD cchValue)
-{
- DWORD dwAttrib = FILE_ATTRIBUTE_SYSTEM;
- WCHAR wszFolderPath[MAX_PATH];
-
- /* Hack around not having system attribute on non-Windows file systems */
- if (0)
- dwAttrib = _ILGetFileAttributes(pidl, NULL, 0);
-
- if (dwAttrib & FILE_ATTRIBUTE_SYSTEM)
- {
- if (!SHGetPathFromIDListW(pidl, wszFolderPath))
- return FALSE;
-
- return SHELL32_GetCustomFolderAttributeFromPath(wszFolderPath, pwszHeading,
- pwszAttribute, pwszValue, cchValue);
- }
- return FALSE;
-}
-
-BOOL SHELL32_GetCustomFolderAttributes(
- LPCITEMIDLIST pidl, LPCWSTR pwszHeading,
- LPWSTR pwszValue, DWORD cchValue)
-{
- DWORD dwAttrib = FILE_ATTRIBUTE_SYSTEM;
- WCHAR wszFolderPath[MAX_PATH];
-
- /* Hack around not having system attribute on non-Windows file systems */
- dwAttrib = _ILGetFileAttributes(pidl, NULL, 0);
-
- if (dwAttrib & FILE_ATTRIBUTE_SYSTEM)
- {
- if (!SHGetPathFromIDListW(pidl, wszFolderPath))
- return FALSE;
-
- static const WCHAR wszDesktopIni[] =
-
{'d','e','s','k','t','o','p','.','i','n','i',0};
-
- PathAddBackslashW(wszFolderPath);
- PathAppendW(wszFolderPath, wszDesktopIni);
- return GetPrivateProfileSectionW(pwszHeading, pwszValue, cchValue,
wszFolderPath);
- }
- return FALSE;
-}
-
/***************************************************************************
* GetNextElement (internal function)
@@ -276,6 +225,9 @@
HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot,
LPCWSTR pathRoot, LPCITEMIDLIST pidlComplete, REFIID riid,
LPVOID * ppvOut)
{
+ static const WCHAR wszDotShellClassInfo[] = {
+
'.','S','h','e','l','l','C','l','a','s','s','I','n','f','o',0
};
+
GUID const *clsid;
CComPtr<IShellFolder> pSF;
HRESULT hr;