From ed7c0959c696cbb4073251c2b4f537d4f9ec436d Mon Sep 17 00:00:00 2001 From: David Quintana Date: Thu, 27 Aug 2015 16:37:13 +0000 Subject: [PATCH] [SHELL32] The desktop.ini file is only meant to be read if the folder has the R (read-only) or S (system) attributes. If this causes your favorite folder to stop showing the icon, use "attrib +r " or edit it from the properties dialog. When we add the desktop.ini files, we will also need to add the R attribute to their respective folders. Followup to CORE-9002 svn path=/trunk/; revision=68834 --- reactos/dll/win32/shell32/folders.cpp | 54 ++++++++++++++------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/reactos/dll/win32/shell32/folders.cpp b/reactos/dll/win32/shell32/folders.cpp index ec9818b9ee5..90704e130cd 100644 --- a/reactos/dll/win32/shell32/folders.cpp +++ b/reactos/dll/win32/shell32/folders.cpp @@ -34,36 +34,40 @@ static HRESULT getIconLocationForFolder(LPCITEMIDLIST pidl, UINT uFlags, static const WCHAR iconIndex[] = { 'I', 'c', 'o', 'n', 'I', 'n', 'd', 'e', 'x', 0 }; 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)) + if (!(uFlags & GIL_DEFAULTICON) && (_ILGetFileAttributes(ILFindLastID(pidl), NULL, 0) & (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY)) != 0 ) { - WCHAR wszPath[MAX_PATH]; - WCHAR wszCLSIDValue[CHARS_IN_GUID]; + WCHAR wszFolderPath[MAX_PATH]; - if (GetPrivateProfileStringW(shellClassInfo, iconFile, NULL, wszPath, MAX_PATH, wszFolderPath)) - { - ExpandEnvironmentStringsW(wszPath, szIconFile, cchMax); + if (!SHGetPathFromIDListW(pidl, wszFolderPath)) + return FALSE; - *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)) + PathAppendW(wszFolderPath, wszDesktopIni); + + if (PathFileExistsW(wszFolderPath)) { - *piIndex = icon_idx; - 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; - return S_OK; + 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; + 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; + return S_OK; + } } }