Commit 7114f8c3 authored by Martin Fuchs's avatar Martin Fuchs Committed by Alexandre Julliard

shell32: Fix folder icon index when read from registry.

Change "DWORD dwNr" into "int icon_idx" at several places.
parent 6d88d5ad
...@@ -164,31 +164,31 @@ static BOOL HCR_RegOpenClassIDKey(REFIID riid, HKEY *hkey) ...@@ -164,31 +164,31 @@ static BOOL HCR_RegOpenClassIDKey(REFIID riid, HKEY *hkey)
return !RegOpenKeyExA(HKEY_CLASSES_ROOT, xriid, 0, KEY_READ, hkey); return !RegOpenKeyExA(HKEY_CLASSES_ROOT, xriid, 0, KEY_READ, hkey);
} }
static BOOL HCR_RegGetDefaultIconW(HKEY hkey, LPWSTR szDest, DWORD len, LPDWORD dwNr) static BOOL HCR_RegGetDefaultIconW(HKEY hkey, LPWSTR szDest, DWORD len, int* picon_idx)
{ {
DWORD dwType; DWORD dwType;
WCHAR sTemp[MAX_PATH]; WCHAR sTemp[MAX_PATH];
WCHAR sNum[5]; WCHAR sNum[5];
if (!RegQueryValueExW(hkey, NULL, 0, &dwType, (LPBYTE)szDest, &len)) if (!RegQueryValueExW(hkey, NULL, 0, &dwType, (LPBYTE)szDest, &len))
{ {
if (dwType == REG_EXPAND_SZ) if (dwType == REG_EXPAND_SZ)
{ {
ExpandEnvironmentStringsW(szDest, sTemp, MAX_PATH); ExpandEnvironmentStringsW(szDest, sTemp, MAX_PATH);
lstrcpynW(szDest, sTemp, len); lstrcpynW(szDest, sTemp, len);
} }
if (ParseFieldW (szDest, 2, sNum, 5)) if (ParseFieldW (szDest, 2, sNum, 5))
*dwNr = atoiW(sNum); *picon_idx = atoiW(sNum);
else else
*dwNr=0; /* sometimes the icon number is missing */ *picon_idx=0; /* sometimes the icon number is missing */
ParseFieldW (szDest, 1, szDest, len); ParseFieldW (szDest, 1, szDest, len);
PathUnquoteSpacesW(szDest); PathUnquoteSpacesW(szDest);
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
static BOOL HCR_RegGetDefaultIconA(HKEY hkey, LPSTR szDest, DWORD len, LPDWORD dwNr) static BOOL HCR_RegGetDefaultIconA(HKEY hkey, LPSTR szDest, DWORD len, int* picon_idx)
{ {
DWORD dwType; DWORD dwType;
char sTemp[MAX_PATH]; char sTemp[MAX_PATH];
...@@ -202,9 +202,9 @@ static BOOL HCR_RegGetDefaultIconA(HKEY hkey, LPSTR szDest, DWORD len, LPDWORD d ...@@ -202,9 +202,9 @@ static BOOL HCR_RegGetDefaultIconA(HKEY hkey, LPSTR szDest, DWORD len, LPDWORD d
lstrcpynA(szDest, sTemp, len); lstrcpynA(szDest, sTemp, len);
} }
if (ParseFieldA (szDest, 2, sNum, 5)) if (ParseFieldA (szDest, 2, sNum, 5))
*dwNr=atoi(sNum); *picon_idx=atoi(sNum);
else else
*dwNr=0; /* sometimes the icon number is missing */ *picon_idx=0; /* sometimes the icon number is missing */
ParseFieldA (szDest, 1, szDest, len); ParseFieldA (szDest, 1, szDest, len);
PathUnquoteSpacesA(szDest); PathUnquoteSpacesA(szDest);
return TRUE; return TRUE;
...@@ -212,7 +212,7 @@ static BOOL HCR_RegGetDefaultIconA(HKEY hkey, LPSTR szDest, DWORD len, LPDWORD d ...@@ -212,7 +212,7 @@ static BOOL HCR_RegGetDefaultIconA(HKEY hkey, LPSTR szDest, DWORD len, LPDWORD d
return FALSE; return FALSE;
} }
BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, LPDWORD dwNr) BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, int* picon_idx)
{ {
static const WCHAR swDefaultIcon[] = {'\\','D','e','f','a','u','l','t','I','c','o','n',0}; static const WCHAR swDefaultIcon[] = {'\\','D','e','f','a','u','l','t','I','c','o','n',0};
HKEY hkey; HKEY hkey;
...@@ -226,19 +226,19 @@ BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, LPDWORD dwNr ...@@ -226,19 +226,19 @@ BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, LPDWORD dwNr
if (!RegOpenKeyExW(HKEY_CLASSES_ROOT, sTemp, 0, 0x02000000, &hkey)) if (!RegOpenKeyExW(HKEY_CLASSES_ROOT, sTemp, 0, 0x02000000, &hkey))
{ {
ret = HCR_RegGetDefaultIconW(hkey, szDest, len, dwNr); ret = HCR_RegGetDefaultIconW(hkey, szDest, len, picon_idx);
RegCloseKey(hkey); RegCloseKey(hkey);
} }
if(ret) if(ret)
TRACE("-- %s %li\n", debugstr_w(szDest), *dwNr ); TRACE("-- %s %i\n", debugstr_w(szDest), *picon_idx);
else else
TRACE("-- not found\n"); TRACE("-- not found\n");
return ret; return ret;
} }
BOOL HCR_GetDefaultIconA(LPCSTR szClass, LPSTR szDest, DWORD len, LPDWORD dwNr) BOOL HCR_GetDefaultIconA(LPCSTR szClass, LPSTR szDest, DWORD len, int* picon_idx)
{ {
HKEY hkey; HKEY hkey;
char sTemp[MAX_PATH]; char sTemp[MAX_PATH];
...@@ -250,24 +250,24 @@ BOOL HCR_GetDefaultIconA(LPCSTR szClass, LPSTR szDest, DWORD len, LPDWORD dwNr) ...@@ -250,24 +250,24 @@ BOOL HCR_GetDefaultIconA(LPCSTR szClass, LPSTR szDest, DWORD len, LPDWORD dwNr)
if (!RegOpenKeyExA(HKEY_CLASSES_ROOT, sTemp, 0, 0x02000000, &hkey)) if (!RegOpenKeyExA(HKEY_CLASSES_ROOT, sTemp, 0, 0x02000000, &hkey))
{ {
ret = HCR_RegGetDefaultIconA(hkey, szDest, len, dwNr); ret = HCR_RegGetDefaultIconA(hkey, szDest, len, picon_idx);
RegCloseKey(hkey); RegCloseKey(hkey);
} }
TRACE("-- %s %li\n", szDest, *dwNr ); TRACE("-- %s %i\n", szDest, *picon_idx);
return ret; return ret;
} }
BOOL HCR_GetDefaultIconFromGUIDW(REFIID riid, LPWSTR szDest, DWORD len, LPDWORD dwNr) BOOL HCR_GetDefaultIconFromGUIDW(REFIID riid, LPWSTR szDest, DWORD len, int* picon_idx)
{ {
HKEY hkey; HKEY hkey;
BOOL ret = FALSE; BOOL ret = FALSE;
if (HCR_RegOpenClassIDKey(riid, &hkey)) if (HCR_RegOpenClassIDKey(riid, &hkey))
{ {
ret = HCR_RegGetDefaultIconW(hkey, szDest, len, dwNr); ret = HCR_RegGetDefaultIconW(hkey, szDest, len, picon_idx);
RegCloseKey(hkey); RegCloseKey(hkey);
} }
TRACE("-- %s %li\n", debugstr_w(szDest), *dwNr ); TRACE("-- %s %i\n", debugstr_w(szDest), *picon_idx);
return ret; return ret;
} }
......
...@@ -166,7 +166,7 @@ static HRESULT getIconLocationForFolder(IExtractIconW *iface, UINT uFlags, ...@@ -166,7 +166,7 @@ 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;
DWORD dwNr; int icon_idx;
WCHAR wszPath[MAX_PATH]; WCHAR wszPath[MAX_PATH];
WCHAR wszCLSIDValue[CHARS_IN_GUID]; 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 shellClassInfo[] = { '.','S','h','e','l','l','C','l','a','s','s','I','n','f','o',0 };
...@@ -185,27 +185,32 @@ static HRESULT getIconLocationForFolder(IExtractIconW *iface, UINT uFlags, ...@@ -185,27 +185,32 @@ static HRESULT getIconLocationForFolder(IExtractIconW *iface, UINT uFlags,
} }
else if (SHELL32_GetCustomFolderAttribute(This->pidl, shellClassInfo, clsid, else if (SHELL32_GetCustomFolderAttribute(This->pidl, shellClassInfo, clsid,
wszCLSIDValue, CHARS_IN_GUID) && wszCLSIDValue, CHARS_IN_GUID) &&
HCR_GetDefaultIconW(wszCLSIDValue, szIconFile, cchMax, &dwNr)) HCR_GetDefaultIconW(wszCLSIDValue, szIconFile, cchMax, &icon_idx))
{ {
*piIndex = dwNr; *piIndex = icon_idx;
} }
else if (SHELL32_GetCustomFolderAttribute(This->pidl, shellClassInfo, clsid2, else if (SHELL32_GetCustomFolderAttribute(This->pidl, shellClassInfo, clsid2,
wszCLSIDValue, CHARS_IN_GUID) && wszCLSIDValue, CHARS_IN_GUID) &&
HCR_GetDefaultIconW(wszCLSIDValue, szIconFile, cchMax, &dwNr)) HCR_GetDefaultIconW(wszCLSIDValue, szIconFile, cchMax, &icon_idx))
{ {
*piIndex = dwNr; *piIndex = icon_idx;
} }
else else
{ {
static const WCHAR folder[] = { 'F','o','l','d','e','r',0 }; static const WCHAR folder[] = { 'F','o','l','d','e','r',0 };
if (!HCR_GetDefaultIconW(folder, szIconFile, cchMax, &dwNr)) if (!HCR_GetDefaultIconW(folder, szIconFile, cchMax, &icon_idx))
{ {
lstrcpynW(szIconFile, swShell32Name, cchMax); lstrcpynW(szIconFile, swShell32Name, cchMax);
dwNr = IDI_SHELL_FOLDER; icon_idx = -IDI_SHELL_FOLDER;
} }
*piIndex = -((uFlags & GIL_OPENICON) ? dwNr + 1 : dwNr);
if (uFlags & GIL_OPENICON)
*piIndex = icon_idx<0? icon_idx-1: icon_idx+1;
else
*piIndex = icon_idx;
} }
return S_OK; return S_OK;
} }
...@@ -227,7 +232,7 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation( ...@@ -227,7 +232,7 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation(
IExtractIconWImpl *This = (IExtractIconWImpl *)iface; IExtractIconWImpl *This = (IExtractIconWImpl *)iface;
char sTemp[MAX_PATH]; char sTemp[MAX_PATH];
DWORD dwNr; int icon_idx;
GUID const * riid; GUID const * riid;
LPITEMIDLIST pSimplePidl = ILFindLastID(This->pidl); LPITEMIDLIST pSimplePidl = ILFindLastID(This->pidl);
...@@ -256,9 +261,9 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation( ...@@ -256,9 +261,9 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation(
riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7]); riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7]);
if (HCR_GetDefaultIconW(xriid, szIconFile, cchMax, &dwNr)) if (HCR_GetDefaultIconW(xriid, szIconFile, cchMax, &icon_idx))
{ {
*piIndex = dwNr; *piIndex = icon_idx;
} }
else else
{ {
...@@ -301,9 +306,9 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation( ...@@ -301,9 +306,9 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation(
} }
else else
{ {
if (HCR_GetDefaultIconW(drive, szIconFile, cchMax, &dwNr)) if (HCR_GetDefaultIconW(drive, szIconFile, cchMax, &icon_idx))
{ {
*piIndex = dwNr; *piIndex = icon_idx;
} }
else else
{ {
...@@ -329,7 +334,7 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation( ...@@ -329,7 +334,7 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation(
else if (_ILGetExtension(pSimplePidl, sTemp, MAX_PATH)) else if (_ILGetExtension(pSimplePidl, sTemp, MAX_PATH))
{ {
if (HCR_MapTypeToValueA(sTemp, sTemp, MAX_PATH, TRUE) if (HCR_MapTypeToValueA(sTemp, sTemp, MAX_PATH, TRUE)
&& HCR_GetDefaultIconA(sTemp, sTemp, MAX_PATH, &dwNr)) && HCR_GetDefaultIconA(sTemp, sTemp, MAX_PATH, &icon_idx))
{ {
if (!lstrcmpA("%1", sTemp)) /* icon is in the file */ if (!lstrcmpA("%1", sTemp)) /* icon is in the file */
{ {
...@@ -339,7 +344,7 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation( ...@@ -339,7 +344,7 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation(
else else
{ {
MultiByteToWideChar(CP_ACP, 0, sTemp, -1, szIconFile, cchMax); MultiByteToWideChar(CP_ACP, 0, sTemp, -1, szIconFile, cchMax);
*piIndex = dwNr; *piIndex = icon_idx;
} }
found = TRUE; found = TRUE;
......
...@@ -97,7 +97,7 @@ static INT CALLBACK SIC_CompareEntries( LPVOID p1, LPVOID p2, LPARAM lparam) ...@@ -97,7 +97,7 @@ static INT CALLBACK SIC_CompareEntries( LPVOID p1, LPVOID p2, LPARAM lparam)
} }
/* declare SIC_LoadOverlayIcon() */ /* declare SIC_LoadOverlayIcon() */
static int SIC_LoadOverlayIcon(int idx); static int SIC_LoadOverlayIcon(int icon_idx);
/***************************************************************************** /*****************************************************************************
* SIC_OverlayShortcutImage [internal] * SIC_OverlayShortcutImage [internal]
...@@ -467,7 +467,7 @@ void SIC_Destroy(void) ...@@ -467,7 +467,7 @@ void SIC_Destroy(void)
* *
* Load a shell overlay icon and return its icon cache index. * Load a shell overlay icon and return its icon cache index.
*/ */
static int SIC_LoadOverlayIcon(int idx) static int SIC_LoadOverlayIcon(int icon_idx)
{ {
WCHAR buffer[1024], wszIdx[8]; WCHAR buffer[1024], wszIdx[8];
HKEY hKeyShellIcons; HKEY hKeyShellIcons;
...@@ -482,13 +482,13 @@ static int SIC_LoadOverlayIcon(int idx) ...@@ -482,13 +482,13 @@ static int SIC_LoadOverlayIcon(int idx)
static const WCHAR wszNumFmt[] = {'%','d',0}; static const WCHAR wszNumFmt[] = {'%','d',0};
iconPath = swShell32Name; /* default: load icon from shell32.dll */ iconPath = swShell32Name; /* default: load icon from shell32.dll */
iconIdx = idx; iconIdx = icon_idx;
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszShellIcons, 0, KEY_READ, &hKeyShellIcons) == ERROR_SUCCESS) if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszShellIcons, 0, KEY_READ, &hKeyShellIcons) == ERROR_SUCCESS)
{ {
DWORD count = sizeof(buffer); DWORD count = sizeof(buffer);
sprintfW(wszIdx, wszNumFmt, idx); sprintfW(wszIdx, wszNumFmt, icon_idx);
/* read icon path and index */ /* read icon path and index */
if (RegQueryValueExW(hKeyShellIcons, wszIdx, NULL, NULL, (LPBYTE)buffer, &count) == ERROR_SUCCESS) if (RegQueryValueExW(hKeyShellIcons, wszIdx, NULL, NULL, (LPBYTE)buffer, &count) == ERROR_SUCCESS)
......
...@@ -536,7 +536,7 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, ...@@ -536,7 +536,7 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
{ {
WCHAR sTemp [MAX_PATH]; WCHAR sTemp [MAX_PATH];
WCHAR * szExt; WCHAR * szExt;
DWORD dwNr=0; int icon_idx=0;
lstrcpynW(sTemp, szFullPath, MAX_PATH); lstrcpynW(sTemp, szFullPath, MAX_PATH);
...@@ -550,14 +550,14 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, ...@@ -550,14 +550,14 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
szExt = (LPWSTR) PathFindExtensionW(sTemp); szExt = (LPWSTR) PathFindExtensionW(sTemp);
if ( szExt && if ( szExt &&
HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) && HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) &&
HCR_GetDefaultIconW(sTemp, sTemp, MAX_PATH, &dwNr)) HCR_GetDefaultIconW(sTemp, sTemp, MAX_PATH, &icon_idx))
{ {
if (!lstrcmpW(p1W,sTemp)) /* icon is in the file */ if (!lstrcmpW(p1W,sTemp)) /* icon is in the file */
strcpyW(sTemp, szFullPath); strcpyW(sTemp, szFullPath);
if (flags & SHGFI_SYSICONINDEX) if (flags & SHGFI_SYSICONINDEX)
{ {
psfi->iIcon = SIC_GetIconIndex(sTemp,dwNr,0); psfi->iIcon = SIC_GetIconIndex(sTemp,icon_idx,0);
if (psfi->iIcon == -1) if (psfi->iIcon == -1)
psfi->iIcon = 0; psfi->iIcon = 0;
} }
...@@ -565,16 +565,16 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, ...@@ -565,16 +565,16 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
{ {
IconNotYetLoaded=FALSE; IconNotYetLoaded=FALSE;
if (flags & SHGFI_SMALLICON) if (flags & SHGFI_SMALLICON)
PrivateExtractIconsW( sTemp,dwNr, PrivateExtractIconsW( sTemp,icon_idx,
GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CXSMICON ),
GetSystemMetrics( SM_CYSMICON ), GetSystemMetrics( SM_CYSMICON ),
&psfi->hIcon, 0, 1, 0); &psfi->hIcon, 0, 1, 0);
else else
PrivateExtractIconsW( sTemp, dwNr, PrivateExtractIconsW( sTemp, icon_idx,
GetSystemMetrics( SM_CXICON), GetSystemMetrics( SM_CXICON),
GetSystemMetrics( SM_CYICON), GetSystemMetrics( SM_CYICON),
&psfi->hIcon, 0, 1, 0); &psfi->hIcon, 0, 1, 0);
psfi->iIcon = dwNr; psfi->iIcon = icon_idx;
} }
} }
} }
......
...@@ -58,13 +58,13 @@ INT SIC_GetIconIndex (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags ); ...@@ -58,13 +58,13 @@ INT SIC_GetIconIndex (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags );
/* Classes Root */ /* Classes Root */
BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, LONG len, BOOL bPrependDot); BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, LONG len, BOOL bPrependDot);
BOOL HCR_GetExecuteCommandW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len ); BOOL HCR_GetExecuteCommandW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len );
BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, LPDWORD dwNr); BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, int* picon_idx);
BOOL HCR_GetDefaultIconFromGUIDW(REFIID riid, LPWSTR szDest, DWORD len, LPDWORD dwNr); BOOL HCR_GetDefaultIconFromGUIDW(REFIID riid, LPWSTR szDest, DWORD len, int* picon_idx);
BOOL HCR_GetClassNameW(REFIID riid, LPWSTR szDest, DWORD len); BOOL HCR_GetClassNameW(REFIID riid, LPWSTR szDest, DWORD len);
/* ANSI versions of above functions, supposed to go away as soon as they are not used anymore */ /* ANSI versions of above functions, supposed to go away as soon as they are not used anymore */
BOOL HCR_MapTypeToValueA(LPCSTR szExtension, LPSTR szFileType, LONG len, BOOL bPrependDot); BOOL HCR_MapTypeToValueA(LPCSTR szExtension, LPSTR szFileType, LONG len, BOOL bPrependDot);
BOOL HCR_GetDefaultIconA(LPCSTR szClass, LPSTR szDest, DWORD len, LPDWORD dwNr); BOOL HCR_GetDefaultIconA(LPCSTR szClass, LPSTR szDest, DWORD len, int* picon_idx);
BOOL HCR_GetClassNameA(REFIID riid, LPSTR szDest, DWORD len); BOOL HCR_GetClassNameA(REFIID riid, LPSTR szDest, DWORD len);
BOOL HCR_GetFolderAttributes(LPCITEMIDLIST pidlFolder, LPDWORD dwAttributes); BOOL HCR_GetFolderAttributes(LPCITEMIDLIST pidlFolder, LPDWORD dwAttributes);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment