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)
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;
WCHAR sTemp[MAX_PATH];
WCHAR sNum[5];
DWORD dwType;
WCHAR sTemp[MAX_PATH];
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)
{
ExpandEnvironmentStringsW(szDest, sTemp, MAX_PATH);
lstrcpynW(szDest, sTemp, len);
}
if (ParseFieldW (szDest, 2, sNum, 5))
*dwNr = atoiW(sNum);
{
ExpandEnvironmentStringsW(szDest, sTemp, MAX_PATH);
lstrcpynW(szDest, sTemp, len);
}
if (ParseFieldW (szDest, 2, sNum, 5))
*picon_idx = atoiW(sNum);
else
*dwNr=0; /* sometimes the icon number is missing */
ParseFieldW (szDest, 1, szDest, len);
*picon_idx=0; /* sometimes the icon number is missing */
ParseFieldW (szDest, 1, szDest, len);
PathUnquoteSpacesW(szDest);
return TRUE;
}
return FALSE;
return TRUE;
}
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;
char sTemp[MAX_PATH];
......@@ -202,9 +202,9 @@ static BOOL HCR_RegGetDefaultIconA(HKEY hkey, LPSTR szDest, DWORD len, LPDWORD d
lstrcpynA(szDest, sTemp, len);
}
if (ParseFieldA (szDest, 2, sNum, 5))
*dwNr=atoi(sNum);
*picon_idx=atoi(sNum);
else
*dwNr=0; /* sometimes the icon number is missing */
*picon_idx=0; /* sometimes the icon number is missing */
ParseFieldA (szDest, 1, szDest, len);
PathUnquoteSpacesA(szDest);
return TRUE;
......@@ -212,7 +212,7 @@ static BOOL HCR_RegGetDefaultIconA(HKEY hkey, LPSTR szDest, DWORD len, LPDWORD d
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};
HKEY hkey;
......@@ -226,19 +226,19 @@ BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, LPDWORD dwNr
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);
}
if(ret)
TRACE("-- %s %li\n", debugstr_w(szDest), *dwNr );
TRACE("-- %s %i\n", debugstr_w(szDest), *picon_idx);
else
TRACE("-- not found\n");
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;
char sTemp[MAX_PATH];
......@@ -250,24 +250,24 @@ BOOL HCR_GetDefaultIconA(LPCSTR szClass, LPSTR szDest, DWORD len, LPDWORD dwNr)
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);
}
TRACE("-- %s %li\n", szDest, *dwNr );
TRACE("-- %s %i\n", szDest, *picon_idx);
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;
BOOL ret = FALSE;
if (HCR_RegOpenClassIDKey(riid, &hkey))
{
ret = HCR_RegGetDefaultIconW(hkey, szDest, len, dwNr);
ret = HCR_RegGetDefaultIconW(hkey, szDest, len, picon_idx);
RegCloseKey(hkey);
}
TRACE("-- %s %li\n", debugstr_w(szDest), *dwNr );
TRACE("-- %s %i\n", debugstr_w(szDest), *picon_idx);
return ret;
}
......
......@@ -166,7 +166,7 @@ static HRESULT getIconLocationForFolder(IExtractIconW *iface, UINT uFlags,
LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
{
IExtractIconWImpl *This = (IExtractIconWImpl *)iface;
DWORD dwNr;
int icon_idx;
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 };
......@@ -185,27 +185,32 @@ static HRESULT getIconLocationForFolder(IExtractIconW *iface, UINT uFlags,
}
else if (SHELL32_GetCustomFolderAttribute(This->pidl, shellClassInfo, clsid,
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,
wszCLSIDValue, CHARS_IN_GUID) &&
HCR_GetDefaultIconW(wszCLSIDValue, szIconFile, cchMax, &dwNr))
HCR_GetDefaultIconW(wszCLSIDValue, szIconFile, cchMax, &icon_idx))
{
*piIndex = dwNr;
*piIndex = icon_idx;
}
else
{
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);
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;
}
......@@ -227,7 +232,7 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation(
IExtractIconWImpl *This = (IExtractIconWImpl *)iface;
char sTemp[MAX_PATH];
DWORD dwNr;
int icon_idx;
GUID const * riid;
LPITEMIDLIST pSimplePidl = ILFindLastID(This->pidl);
......@@ -256,9 +261,9 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation(
riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
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
{
......@@ -301,9 +306,9 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation(
}
else
{
if (HCR_GetDefaultIconW(drive, szIconFile, cchMax, &dwNr))
if (HCR_GetDefaultIconW(drive, szIconFile, cchMax, &icon_idx))
{
*piIndex = dwNr;
*piIndex = icon_idx;
}
else
{
......@@ -329,7 +334,7 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation(
else if (_ILGetExtension(pSimplePidl, sTemp, MAX_PATH))
{
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 */
{
......@@ -339,7 +344,7 @@ static HRESULT WINAPI IExtractIconW_fnGetIconLocation(
else
{
MultiByteToWideChar(CP_ACP, 0, sTemp, -1, szIconFile, cchMax);
*piIndex = dwNr;
*piIndex = icon_idx;
}
found = TRUE;
......
......@@ -97,7 +97,7 @@ static INT CALLBACK SIC_CompareEntries( LPVOID p1, LPVOID p2, LPARAM lparam)
}
/* declare SIC_LoadOverlayIcon() */
static int SIC_LoadOverlayIcon(int idx);
static int SIC_LoadOverlayIcon(int icon_idx);
/*****************************************************************************
* SIC_OverlayShortcutImage [internal]
......@@ -467,7 +467,7 @@ void SIC_Destroy(void)
*
* 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];
HKEY hKeyShellIcons;
......@@ -482,13 +482,13 @@ static int SIC_LoadOverlayIcon(int idx)
static const WCHAR wszNumFmt[] = {'%','d',0};
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)
{
DWORD count = sizeof(buffer);
sprintfW(wszIdx, wszNumFmt, idx);
sprintfW(wszIdx, wszNumFmt, icon_idx);
/* read icon path and index */
if (RegQueryValueExW(hKeyShellIcons, wszIdx, NULL, NULL, (LPBYTE)buffer, &count) == ERROR_SUCCESS)
......
......@@ -536,7 +536,7 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
{
WCHAR sTemp [MAX_PATH];
WCHAR * szExt;
DWORD dwNr=0;
int icon_idx=0;
lstrcpynW(sTemp, szFullPath, MAX_PATH);
......@@ -550,14 +550,14 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
szExt = (LPWSTR) PathFindExtensionW(sTemp);
if ( szExt &&
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 */
strcpyW(sTemp, szFullPath);
if (flags & SHGFI_SYSICONINDEX)
{
psfi->iIcon = SIC_GetIconIndex(sTemp,dwNr,0);
psfi->iIcon = SIC_GetIconIndex(sTemp,icon_idx,0);
if (psfi->iIcon == -1)
psfi->iIcon = 0;
}
......@@ -565,16 +565,16 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
{
IconNotYetLoaded=FALSE;
if (flags & SHGFI_SMALLICON)
PrivateExtractIconsW( sTemp,dwNr,
PrivateExtractIconsW( sTemp,icon_idx,
GetSystemMetrics( SM_CXSMICON ),
GetSystemMetrics( SM_CYSMICON ),
&psfi->hIcon, 0, 1, 0);
else
PrivateExtractIconsW( sTemp, dwNr,
PrivateExtractIconsW( sTemp, icon_idx,
GetSystemMetrics( SM_CXICON),
GetSystemMetrics( SM_CYICON),
&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 );
/* Classes Root */
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_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, LPDWORD dwNr);
BOOL HCR_GetDefaultIconFromGUIDW(REFIID riid, 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, int* picon_idx);
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 */
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_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