Simplify getting custom icons for a folder by utilising the new
SHELL32_GetCustomFolderAttribute function.
This commit is contained in:
parent
5ad2d3517f
commit
8e80468170
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
|
#include "winerror.h"
|
||||||
#include "objbase.h"
|
#include "objbase.h"
|
||||||
#include "undocshell.h"
|
#include "undocshell.h"
|
||||||
#include "shlguid.h"
|
#include "shlguid.h"
|
||||||
|
@ -34,10 +35,11 @@
|
||||||
#include "shlwapi.h"
|
#include "shlwapi.h"
|
||||||
|
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
#include "winerror.h"
|
#include "wine/unicode.h"
|
||||||
|
|
||||||
#include "pidl.h"
|
#include "pidl.h"
|
||||||
#include "shell32_main.h"
|
#include "shell32_main.h"
|
||||||
|
#include "shfldr.h"
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
||||||
|
|
||||||
|
@ -156,64 +158,36 @@ static HRESULT getIconLocationForFolder(IExtractIconW *iface, UINT uFlags,
|
||||||
LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
|
LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
|
||||||
{
|
{
|
||||||
IExtractIconWImpl *This = (IExtractIconWImpl *)iface;
|
IExtractIconWImpl *This = (IExtractIconWImpl *)iface;
|
||||||
|
|
||||||
WCHAR path[MAX_PATH];
|
|
||||||
BOOL found = FALSE;
|
|
||||||
DWORD dwNr;
|
DWORD dwNr;
|
||||||
|
WCHAR wszPath[MAX_PATH];
|
||||||
if (SUCCEEDED(SHGetPathFromIDListW(This->pidl, 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 desktopIni[] = { 'D','e','s','k','t','o','p','.',
|
static const WCHAR iconFile[] = { 'I','c','o','n','F','i','l','e',0 };
|
||||||
'i','n','i',0 };
|
|
||||||
HANDLE hFile;
|
|
||||||
|
|
||||||
PathAppendW(path, desktopIni);
|
|
||||||
if ((hFile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL,
|
|
||||||
OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
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 clsid[] = { 'C','L','S','I','D',0 };
|
||||||
static const WCHAR clsid2[] = { 'C','L','S','I','D','2',0 };
|
static const WCHAR clsid2[] = { 'C','L','S','I','D','2',0 };
|
||||||
static const WCHAR defStr[] = { 0 };
|
static const WCHAR iconIndex[] = { 'I','c','o','n','I','n','d','e','x',0 };
|
||||||
WCHAR clsidStr[39];
|
|
||||||
|
|
||||||
CloseHandle(hFile);
|
if (SHELL32_GetCustomFolderAttribute(This->pidl, shellClassInfo, iconFile,
|
||||||
if (GetPrivateProfileStringW(shellClassInfo, iconFile, defStr,
|
wszPath, MAX_PATH))
|
||||||
szIconFile, cchMax, path) && strlenW(szIconFile))
|
|
||||||
{
|
{
|
||||||
static const WCHAR iconIndex[] = { 'I','c','o','n',
|
WCHAR wszIconIndex[10];
|
||||||
'I','n','d','e','x',0 };
|
SHELL32_GetCustomFolderAttribute(This->pidl, shellClassInfo, iconIndex,
|
||||||
|
wszIconIndex, 10);
|
||||||
found = TRUE;
|
*piIndex = atoiW(wszIconIndex);
|
||||||
*piIndex = (int)GetPrivateProfileIntW(shellClassInfo, iconIndex,
|
|
||||||
0, path);
|
|
||||||
}
|
}
|
||||||
else if (GetPrivateProfileStringW(shellClassInfo, clsid, defStr,
|
else if (SHELL32_GetCustomFolderAttribute(This->pidl, shellClassInfo, clsid,
|
||||||
clsidStr, sizeof(clsidStr) / sizeof(WCHAR), path) &&
|
wszCLSIDValue, CHARS_IN_GUID) &&
|
||||||
strlenW(clsidStr))
|
HCR_GetDefaultIconW(wszCLSIDValue, szIconFile, cchMax, &dwNr))
|
||||||
{
|
|
||||||
if (HCR_GetDefaultIconW(clsidStr, szIconFile, cchMax, &dwNr))
|
|
||||||
{
|
{
|
||||||
*piIndex = dwNr;
|
*piIndex = dwNr;
|
||||||
found = TRUE;
|
|
||||||
}
|
}
|
||||||
}
|
else if (SHELL32_GetCustomFolderAttribute(This->pidl, shellClassInfo, clsid2,
|
||||||
else if (GetPrivateProfileStringW(shellClassInfo, clsid2, defStr,
|
wszCLSIDValue, CHARS_IN_GUID) &&
|
||||||
clsidStr, sizeof(clsidStr) / sizeof(WCHAR), path) &&
|
HCR_GetDefaultIconW(wszCLSIDValue, szIconFile, cchMax, &dwNr))
|
||||||
strlenW(clsidStr))
|
|
||||||
{
|
|
||||||
if (HCR_GetDefaultIconW(clsidStr, szIconFile, cchMax, &dwNr))
|
|
||||||
{
|
{
|
||||||
*piIndex = dwNr;
|
*piIndex = dwNr;
|
||||||
found = TRUE;
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found)
|
|
||||||
{
|
{
|
||||||
static const WCHAR folder[] = { 'F','o','l','d','e','r',0 };
|
static const WCHAR folder[] = { 'F','o','l','d','e','r',0 };
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue