/***************************************************************************** * SIC_GetIconIndex [internal] * * Parameters * sSourceFile [IN] filename of file containing the icon * index [IN] index/resID (negated) in this file * * NOTES * look in the cache for a proper icon. if not available the icon is taken * from the file and cached */ INT SIC_GetIconIndex (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags ) { SIC_ENTRY sice; INT ret, index = INVALID_INDEX; WCHAR path[MAX_PATH]; TRACE("%s %i\n", debugstr_w(sSourceFile), dwSourceIndex); GetFullPathNameW(sSourceFile, MAX_PATH, path, NULL); sice.sSourceFile = path; sice.dwSourceIndex = dwSourceIndex; sice.dwFlags = dwFlags; EnterCriticalSection(&SHELL32_SicCS); if (NULL != DPA_GetPtr (sic_hdpa, 0)) { /* search linear from position 0*/ index = DPA_Search (sic_hdpa, &sice, 0, SIC_CompareEntries, 0, DPAS_SORTED); } if ( INVALID_INDEX == index ) { ret = SIC_LoadIcon (sSourceFile, dwSourceIndex, dwFlags); } else { TRACE("-- found\n"); ret = ((LPSIC_ENTRY)DPA_GetPtr(sic_hdpa, index))->dwListIndex; } LeaveCriticalSection(&SHELL32_SicCS); return ret; }
HRESULT TRASH_EnumItems(const WCHAR *path, LPITEMIDLIST **pidls, int *count) { int ti_count; int pos=0, i; HRESULT err = E_OUTOFMEMORY; HDPA tinfs; if(path) FIXME("Ignoring path = %s\n", debugstr_w(path)); if (!TRASH_EnsureInitialized()) return E_FAIL; tinfs = enum_bucket_trashinfos(home_trash, &ti_count); if (tinfs == NULL) return E_FAIL; *pidls = SHAlloc(sizeof(LPITEMIDLIST)*ti_count); if (!*pidls) goto failed; for (i=0; i<ti_count; i++) { WIN32_FIND_DATAW data; LPCSTR filename; filename = DPA_GetPtr(tinfs, i); if (FAILED(err = TRASH_GetDetails(home_trash, filename, &data))) goto failed; if (err == S_FALSE) continue; if (FAILED(err = TRASH_CreateSimplePIDL(filename, &data, &(*pidls)[pos]))) goto failed; pos++; } *count = pos; DPA_DestroyCallback(tinfs, free_item_callback, NULL); return S_OK; failed: if (*pidls != NULL) { int j; for (j=0; j<pos; j++) SHFree((*pidls)[j]); SHFree(*pidls); } DPA_DestroyCallback(tinfs, free_item_callback, NULL); return err; }
HRESULT CMenuSFToolbar::FillToolbar(BOOL clearFirst) { HRESULT hr; CComPtr<IEnumIDList> eidl; hr = m_shellFolder->EnumObjects(GetToolbar(), SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &eidl); if (FAILED_UNEXPECTEDLY(hr)) return hr; HDPA dpaSort = DPA_Create(10); LPITEMIDLIST item = NULL; hr = eidl->Next(1, &item, NULL); while (hr == S_OK) { if (m_menuBand->_CallCBWithItemPidl(item, 0x10000000, 0, 0) == S_FALSE) { DPA_AppendPtr(dpaSort, ILClone(item)); } hr = eidl->Next(1, &item, NULL); } // If no items were added, show the "empty" placeholder if (DPA_GetPtrCount(dpaSort) == 0) { DPA_Destroy(dpaSort); return AddPlaceholder(); } TRACE("FillToolbar added %d items to the DPA\n", DPA_GetPtrCount(dpaSort)); DPA_Sort(dpaSort, PidlListSort, (LPARAM) m_shellFolder.p); for (int i = 0; i<DPA_GetPtrCount(dpaSort);) { PWSTR MenuString; INT index = 0; INT indexOpen = 0; STRRET sr = { STRRET_CSTR, { 0 } }; item = (LPITEMIDLIST)DPA_GetPtr(dpaSort, i); hr = m_shellFolder->GetDisplayNameOf(item, SIGDN_NORMALDISPLAY, &sr); if (FAILED_UNEXPECTEDLY(hr)) { DPA_Destroy(dpaSort); return hr; } StrRetToStr(&sr, NULL, &MenuString); index = SHMapPIDLToSystemImageListIndex(m_shellFolder, item, &indexOpen); LPCITEMIDLIST itemc = item; SFGAOF attrs = SFGAO_FOLDER; hr = m_shellFolder->GetAttributesOf(1, &itemc, &attrs); DWORD_PTR dwData = reinterpret_cast<DWORD_PTR>(item); // Fetch next item already, so we know if the current one is the last i++; AddButton(i, MenuString, attrs & SFGAO_FOLDER, index, dwData, i >= DPA_GetPtrCount(dpaSort)); CoTaskMemFree(MenuString); } DPA_Destroy(dpaSort); return hr; }