HRESULT CDrivesExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID riid, LPVOID * ppvOut) { CComPtr<IDefaultExtractIconInit> initIcon; HRESULT hr = SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit, &initIcon)); if (FAILED_UNEXPECTEDLY(hr)) return hr; CHAR* pszDrive = _ILGetDataPointer(pidl)->u.drive.szDriveName; WCHAR wTemp[MAX_PATH]; int icon_idx = -1; if (pszDrive) { switch(GetDriveTypeA(pszDrive)) { case DRIVE_REMOVABLE: icon_idx = IDI_SHELL_3_14_FLOPPY; break; case DRIVE_CDROM: icon_idx = IDI_SHELL_CDROM; break; case DRIVE_REMOTE: icon_idx = IDI_SHELL_NETDRIVE; break; case DRIVE_RAMDISK: icon_idx = IDI_SHELL_RAMDISK; break; case DRIVE_NO_ROOT_DIR: icon_idx = IDI_SHELL_CDROM; break; } } if (icon_idx != -1) { initIcon->SetNormalIcon(swShell32Name, -icon_idx); } else { if (HCR_GetIconW(L"Drive", wTemp, NULL, MAX_PATH, &icon_idx)) initIcon->SetNormalIcon(wTemp, icon_idx); else initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_DRIVE); } return initIcon->QueryInterface(riid, ppvOut); }
/************************************************************************* * SHGetFileInfoW [SHELL32.@] * */ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags ) { WCHAR szLocation[MAX_PATH], szFullPath[MAX_PATH]; int iIndex; DWORD_PTR ret = TRUE; DWORD dwAttributes = 0; IShellFolder * psfParent = NULL; IExtractIconW * pei = NULL; LPITEMIDLIST pidlLast = NULL, pidl = NULL; HRESULT hr = S_OK; BOOL IconNotYetLoaded=TRUE; UINT uGilFlags = 0; HIMAGELIST big_icons, small_icons; TRACE("%s fattr=0x%x sfi=%p(attr=0x%08x) size=0x%x flags=0x%x\n", (flags & SHGFI_PIDL)? "pidl" : debugstr_w(path), dwFileAttributes, psfi, psfi->dwAttributes, sizeofpsfi, flags); if (!path) return FALSE; /* windows initializes these values regardless of the flags */ if (psfi != NULL) { psfi->szDisplayName[0] = '\0'; psfi->szTypeName[0] = '\0'; psfi->iIcon = 0; } if (!(flags & SHGFI_PIDL)) { /* SHGetFileInfo should work with absolute and relative paths */ if (PathIsRelativeW(path)) { GetCurrentDirectoryW(MAX_PATH, szLocation); PathCombineW(szFullPath, szLocation, path); } else { lstrcpynW(szFullPath, path, MAX_PATH); } } if (flags & SHGFI_EXETYPE) { if (flags != SHGFI_EXETYPE) return 0; return shgfi_get_exe_type(szFullPath); } /* * psfi is NULL normally to query EXE type. If it is NULL, none of the * below makes sense anyway. Windows allows this and just returns FALSE */ if (psfi == NULL) return FALSE; /* * translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES * is not specified. * The pidl functions fail on not existing file names */ if (flags & SHGFI_PIDL) { pidl = ILClone((LPCITEMIDLIST)path); } else if (!(flags & SHGFI_USEFILEATTRIBUTES)) { hr = SHILCreateFromPathW(szFullPath, &pidl, &dwAttributes); } if ((flags & SHGFI_PIDL) || !(flags & SHGFI_USEFILEATTRIBUTES)) { /* get the parent shellfolder */ if (pidl) { hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, (LPCITEMIDLIST*)&pidlLast ); if (SUCCEEDED(hr)) pidlLast = ILClone(pidlLast); ILFree(pidl); } else { ERR("pidl is null!\n"); return FALSE; } } /* get the attributes of the child */ if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES)) { if (!(flags & SHGFI_ATTR_SPECIFIED)) { psfi->dwAttributes = 0xffffffff; } if (psfParent) IShellFolder_GetAttributesOf( psfParent, 1, (LPCITEMIDLIST*)&pidlLast, &(psfi->dwAttributes) ); } /* get the displayname */ if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME)) { if (flags & SHGFI_USEFILEATTRIBUTES && !(flags & SHGFI_PIDL)) { lstrcpyW (psfi->szDisplayName, PathFindFileNameW(szFullPath)); } else { STRRET str; hr = IShellFolder_GetDisplayNameOf( psfParent, pidlLast, SHGDN_INFOLDER, &str); StrRetToStrNW (psfi->szDisplayName, MAX_PATH, &str, pidlLast); } } /* get the type name */ if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME)) { static const WCHAR szFile[] = { 'F','i','l','e',0 }; static const WCHAR szDashFile[] = { '-','f','i','l','e',0 }; if (!(flags & SHGFI_USEFILEATTRIBUTES) || (flags & SHGFI_PIDL)) { char ftype[80]; _ILGetFileType(pidlLast, ftype, 80); MultiByteToWideChar(CP_ACP, 0, ftype, -1, psfi->szTypeName, 80 ); } else { if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) strcatW (psfi->szTypeName, szFile); else { WCHAR sTemp[64]; lstrcpyW(sTemp,PathFindExtensionW(szFullPath)); if (!( HCR_MapTypeToValueW(sTemp, sTemp, 64, TRUE) && HCR_MapTypeToValueW(sTemp, psfi->szTypeName, 80, FALSE ))) { lstrcpynW (psfi->szTypeName, sTemp, 64); strcatW (psfi->szTypeName, szDashFile); } } } } /* ### icons ###*/ Shell_GetImageLists( &big_icons, &small_icons ); if (flags & SHGFI_OPENICON) uGilFlags |= GIL_OPENICON; if (flags & SHGFI_LINKOVERLAY) uGilFlags |= GIL_FORSHORTCUT; else if ((flags&SHGFI_ADDOVERLAYS) || (flags&(SHGFI_ICON|SHGFI_SMALLICON))==SHGFI_ICON) { if (SHELL_IsShortcut(pidlLast)) uGilFlags |= GIL_FORSHORTCUT; } if (flags & SHGFI_OVERLAYINDEX) FIXME("SHGFI_OVERLAYINDEX unhandled\n"); if (flags & SHGFI_SELECTED) FIXME("set icon to selected, stub\n"); if (flags & SHGFI_SHELLICONSIZE) FIXME("set icon to shell size, stub\n"); /* get the iconlocation */ if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION )) { UINT uDummy,uFlags; if (flags & SHGFI_USEFILEATTRIBUTES && !(flags & SHGFI_PIDL)) { if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { lstrcpyW(psfi->szDisplayName, swShell32Name); psfi->iIcon = -IDI_SHELL_FOLDER; } else { WCHAR* szExt; static const WCHAR p1W[] = {'%','1',0}; WCHAR sTemp [MAX_PATH]; szExt = PathFindExtensionW(szFullPath); TRACE("szExt=%s\n", debugstr_w(szExt)); if ( szExt && HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) && HCR_GetIconW(sTemp, sTemp, NULL, MAX_PATH, &psfi->iIcon)) { if (lstrcmpW(p1W, sTemp)) strcpyW(psfi->szDisplayName, sTemp); else { /* the icon is in the file */ strcpyW(psfi->szDisplayName, szFullPath); } } else ret = FALSE; } } else { hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, (LPCITEMIDLIST*)&pidlLast, &IID_IExtractIconW, &uDummy, (LPVOID*)&pei); if (SUCCEEDED(hr)) { hr = IExtractIconW_GetIconLocation(pei, uGilFlags, szLocation, MAX_PATH, &iIndex, &uFlags); if (uFlags & GIL_NOTFILENAME) ret = FALSE; else { lstrcpyW (psfi->szDisplayName, szLocation); psfi->iIcon = iIndex; } IExtractIconW_Release(pei); } } } /* get icon index (or load icon)*/ if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX))) { if (flags & SHGFI_USEFILEATTRIBUTES && !(flags & SHGFI_PIDL)) { WCHAR sTemp [MAX_PATH]; WCHAR * szExt; int icon_idx=0; lstrcpynW(sTemp, szFullPath, MAX_PATH); if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) psfi->iIcon = SIC_GetIconIndex(swShell32Name, -IDI_SHELL_FOLDER, 0); else { static const WCHAR p1W[] = {'%','1',0}; psfi->iIcon = 0; szExt = PathFindExtensionW(sTemp); if ( szExt && HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) && HCR_GetIconW(sTemp, sTemp, NULL, 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,icon_idx,0); if (psfi->iIcon == -1) psfi->iIcon = 0; } else { UINT ret; if (flags & SHGFI_SMALLICON) ret = PrivateExtractIconsW( sTemp,icon_idx, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), &psfi->hIcon, 0, 1, 0); else ret = PrivateExtractIconsW( sTemp, icon_idx, GetSystemMetrics( SM_CXICON), GetSystemMetrics( SM_CYICON), &psfi->hIcon, 0, 1, 0); if (ret != 0 && ret != (UINT)-1) { IconNotYetLoaded=FALSE; psfi->iIcon = icon_idx; } } } } } else { if (!(PidlToSicIndex(psfParent, pidlLast, !(flags & SHGFI_SMALLICON), uGilFlags, &(psfi->iIcon)))) { ret = FALSE; } } if (ret && (flags & SHGFI_SYSICONINDEX)) { if (flags & SHGFI_SMALLICON) ret = (DWORD_PTR)small_icons; else ret = (DWORD_PTR)big_icons; } } /* icon handle */ if (SUCCEEDED(hr) && (flags & SHGFI_ICON) && IconNotYetLoaded) { if (flags & SHGFI_SMALLICON) psfi->hIcon = ImageList_GetIcon( small_icons, psfi->iIcon, ILD_NORMAL); else psfi->hIcon = ImageList_GetIcon( big_icons, psfi->iIcon, ILD_NORMAL); } if (flags & ~SHGFI_KNOWN_FLAGS) FIXME("unknown flags %08x\n", flags & ~SHGFI_KNOWN_FLAGS); if (psfParent) IShellFolder_Release(psfParent); if (hr != S_OK) ret = FALSE; SHFree(pidlLast); TRACE ("icon=%p index=0x%08x attr=0x%08x name=%s type=%s ret=0x%08lx\n", psfi->hIcon, psfi->iIcon, psfi->dwAttributes, debugstr_w(psfi->szDisplayName), debugstr_w(psfi->szTypeName), ret); return ret; }
/************************************************************************** * IExtractIconW_Constructor */ IExtractIconW* IExtractIconW_Constructor(LPCITEMIDLIST pidl) { CComPtr<IDefaultExtractIconInit> initIcon; IExtractIconW *extractIcon; GUID const * riid; int icon_idx; UINT flags; CHAR sTemp[MAX_PATH]; WCHAR wTemp[MAX_PATH]; LPITEMIDLIST pSimplePidl = ILFindLastID(pidl); HRESULT hr; hr = SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit,&initIcon)); if (FAILED(hr)) return NULL; hr = initIcon->QueryInterface(IID_PPV_ARG(IExtractIconW,&extractIcon)); if (FAILED(hr)) return NULL; if (_ILIsDesktop(pSimplePidl)) { initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_DESKTOP); } else if ((riid = _ILGetGUIDPointer(pSimplePidl))) { /* my computer and other shell extensions */ static const WCHAR fmt[] = { 'C', 'L', 'S', 'I', 'D', '\\', '{', '%', '0', '8', 'l', 'x', '-', '%', '0', '4', 'x', '-', '%', '0', '4', 'x', '-', '%', '0', '2', 'x', '%', '0', '2', 'x', '-', '%', '0', '2', 'x', '%', '0', '2', 'x', '%', '0', '2', 'x', '%', '0', '2', 'x', '%', '0', '2', 'x', '%', '0', '2', 'x', '}', 0 }; WCHAR xriid[50]; swprintf(xriid, fmt, riid->Data1, riid->Data2, riid->Data3, riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7]); const WCHAR* iconname = NULL; if (_ILIsBitBucket(pSimplePidl)) { static const WCHAR szFull[] = {'F','u','l','l',0}; static const WCHAR szEmpty[] = {'E','m','p','t','y',0}; IEnumIDList *EnumIDList = NULL; CoInitialize(NULL); IShellFolder2 *psfRecycleBin = NULL; IShellFolder *psfDesktop = NULL; hr = SHGetDesktopFolder(&psfDesktop); if (SUCCEEDED(hr)) hr = psfDesktop->BindToObject(pSimplePidl, NULL, IID_IShellFolder2, (void**) &psfRecycleBin); if (SUCCEEDED(hr)) hr = psfRecycleBin->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &EnumIDList); ULONG itemcount; LPITEMIDLIST pidl = NULL; if (SUCCEEDED(hr) && (hr = EnumIDList->Next(1, &pidl, &itemcount)) == S_OK) { CoTaskMemFree(pidl); iconname = szFull; } else { iconname = szEmpty; } if (psfDesktop) psfDesktop->Release(); if (psfRecycleBin) psfRecycleBin->Release(); if (EnumIDList) EnumIDList->Release(); } if (HCR_GetIconW(xriid, wTemp, iconname, MAX_PATH, &icon_idx)) { initIcon->SetNormalIcon(wTemp, icon_idx); } else { if (IsEqualGUID(*riid, CLSID_MyComputer)) initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_COMPUTER); else if (IsEqualGUID(*riid, CLSID_MyDocuments)) initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_DOCUMENTS); else if (IsEqualGUID(*riid, CLSID_NetworkPlaces)) initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_NETWORK_PLACES); else initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_FOLDER); } } else if (_ILIsDrive (pSimplePidl)) { static const WCHAR drive[] = { 'D', 'r', 'i', 'v', 'e', 0 }; int icon_idx = -1; if (_ILGetDrive(pSimplePidl, sTemp, MAX_PATH)) { switch(GetDriveTypeA(sTemp)) { case DRIVE_REMOVABLE: icon_idx = IDI_SHELL_FLOPPY; break; case DRIVE_CDROM: icon_idx = IDI_SHELL_CDROM; break; case DRIVE_REMOTE: icon_idx = IDI_SHELL_NETDRIVE; break; case DRIVE_RAMDISK: icon_idx = IDI_SHELL_RAMDISK; break; case DRIVE_NO_ROOT_DIR: icon_idx = IDI_SHELL_CDROM; break; } } if (icon_idx != -1) { initIcon->SetNormalIcon(swShell32Name, -icon_idx); } else { if (HCR_GetIconW(drive, wTemp, NULL, MAX_PATH, &icon_idx)) initIcon->SetNormalIcon(wTemp, icon_idx); else initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_DRIVE); } } else if (_ILIsFolder (pSimplePidl)) { if (SUCCEEDED(getIconLocationForFolder( pidl, 0, wTemp, MAX_PATH, &icon_idx, &flags))) { initIcon->SetNormalIcon(wTemp, icon_idx); // FIXME: if/when getIconLocationForFolder does something for // GIL_FORSHORTCUT, code below should be uncommented. and // the following line removed. initIcon->SetShortcutIcon(wTemp, icon_idx); } if (SUCCEEDED(getIconLocationForFolder( pidl, GIL_DEFAULTICON, wTemp, MAX_PATH, &icon_idx, &flags))) { initIcon->SetDefaultIcon(wTemp, icon_idx); } // if (SUCCEEDED(getIconLocationForFolder( // pidl, GIL_FORSHORTCUT, wTemp, MAX_PATH, // &icon_idx, // &flags))) // { // initIcon->SetShortcutIcon(wTemp, icon_idx); // } if (SUCCEEDED(getIconLocationForFolder( pidl, GIL_OPENICON, wTemp, MAX_PATH, &icon_idx, &flags))) { initIcon->SetOpenIcon(wTemp, icon_idx); } } else { BOOL found = FALSE; if (_ILIsCPanelStruct(pSimplePidl)) { if (SUCCEEDED(CPanel_GetIconLocationW(pSimplePidl, wTemp, MAX_PATH, &icon_idx))) found = TRUE; } else if (_ILGetExtension(pSimplePidl, sTemp, MAX_PATH)) { if (HCR_MapTypeToValueA(sTemp, sTemp, MAX_PATH, TRUE) && HCR_GetIconA(sTemp, sTemp, NULL, MAX_PATH, &icon_idx)) { if (!lstrcmpA("%1", sTemp)) /* icon is in the file */ { SHGetPathFromIDListW(pidl, wTemp); icon_idx = 0; } else { MultiByteToWideChar(CP_ACP, 0, sTemp, -1, wTemp, MAX_PATH); } found = TRUE; } else if (!lstrcmpiA(sTemp, "lnkfile")) { /* extract icon from shell shortcut */ CComPtr<IShellFolder> dsf; CComPtr<IShellLinkW> psl; if (SUCCEEDED(SHGetDesktopFolder(&dsf))) { HRESULT hr = dsf->GetUIObjectOf(NULL, 1, (LPCITEMIDLIST*)&pidl, IID_IShellLinkW, NULL, (LPVOID *)&psl); if (SUCCEEDED(hr)) { hr = psl->GetIconLocation(wTemp, MAX_PATH, &icon_idx); if (SUCCEEDED(hr) && *sTemp) found = TRUE; } } } } if (!found) /* default icon */ initIcon->SetNormalIcon(swShell32Name, 0); else initIcon->SetNormalIcon(wTemp, icon_idx); } return extractIcon; }
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) && HCR_GetIconW(wszCLSIDValue, szIconFile, NULL, cchMax, &icon_idx)) { *piIndex = icon_idx; cont=FALSE; } else if (SHELL32_GetCustomFolderAttribute(pidl, shellClassInfo, clsid2, wszCLSIDValue, CHARS_IN_GUID) && 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; }
HRESULT CGuidItemExtractIcon_CreateInstance(LPCITEMIDLIST pidl, REFIID iid, LPVOID * ppvOut) { CComPtr<IDefaultExtractIconInit> initIcon; HRESULT hr; GUID const * riid; int icon_idx; WCHAR wTemp[MAX_PATH]; hr = SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit,&initIcon)); if (FAILED(hr)) return hr; if (_ILIsDesktop(pidl)) { initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_DESKTOP); return initIcon->QueryInterface(iid, ppvOut); } riid = _ILGetGUIDPointer(pidl); if (!riid) return E_FAIL; /* my computer and other shell extensions */ static const WCHAR fmt[] = { 'C', 'L', 'S', 'I', 'D', '\\', '{', '%', '0', '8', 'l', 'x', '-', '%', '0', '4', 'x', '-', '%', '0', '4', 'x', '-', '%', '0', '2', 'x', '%', '0', '2', 'x', '-', '%', '0', '2', 'x', '%', '0', '2', 'x', '%', '0', '2', 'x', '%', '0', '2', 'x', '%', '0', '2', 'x', '%', '0', '2', 'x', '}', 0 }; WCHAR xriid[50]; swprintf(xriid, fmt, riid->Data1, riid->Data2, riid->Data3, riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7]); const WCHAR* iconname = NULL; if (_ILIsBitBucket(pidl)) { static const WCHAR szFull[] = {'F','u','l','l',0}; static const WCHAR szEmpty[] = {'E','m','p','t','y',0}; CComPtr<IEnumIDList> EnumIDList; CoInitialize(NULL); CComPtr<IShellFolder2> psfRecycleBin; CComPtr<IShellFolder> psfDesktop; hr = SHGetDesktopFolder(&psfDesktop); if (SUCCEEDED(hr)) hr = psfDesktop->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder2, &psfRecycleBin)); if (SUCCEEDED(hr)) hr = psfRecycleBin->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &EnumIDList); ULONG itemcount; LPITEMIDLIST pidl = NULL; if (SUCCEEDED(hr) && (hr = EnumIDList->Next(1, &pidl, &itemcount)) == S_OK) { CoTaskMemFree(pidl); iconname = szFull; } else { iconname = szEmpty; } } if (HCR_GetIconW(xriid, wTemp, iconname, MAX_PATH, &icon_idx)) { initIcon->SetNormalIcon(wTemp, icon_idx); } else { if (IsEqualGUID(*riid, CLSID_MyComputer)) initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_COMPUTER); else if (IsEqualGUID(*riid, CLSID_MyDocuments)) initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_DOCUMENTS); else if (IsEqualGUID(*riid, CLSID_NetworkPlaces)) initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_NETWORK_PLACES); else initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_FOLDER); } return initIcon->QueryInterface(iid, ppvOut); }