/***************************************************************************** * 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 (LPCSTR sSourceFile, INT dwSourceIndex ) { SIC_ENTRY sice; INT ret, index = INVALID_INDEX; TRACE("%s %i\n", sSourceFile, dwSourceIndex); sice.sSourceFile = PathFindFileNameA(sSourceFile); sice.dwSourceIndex = dwSourceIndex; EnterCriticalSection(&SHELL32_SicCS); if (NULL != pDPA_GetPtr (sic_hdpa, 0)) { /* search linear from position 0*/ index = pDPA_Search (sic_hdpa, &sice, 0, SIC_CompareEntries, 0, 0); } if ( INVALID_INDEX == index ) { ret = SIC_LoadIcon (sSourceFile, dwSourceIndex); } else { TRACE("-- found\n"); ret = ((LPSIC_ENTRY)pDPA_GetPtr(sic_hdpa, index))->dwListIndex; } LeaveCriticalSection(&SHELL32_SicCS); return ret; }
static BOOL CheckDPA(HDPA dpa, DWORD dwIn, PDWORD pdwOut) { DWORD dwOut = 0; INT i; for(i = 0; i < 8;) { ULONG_PTR ulItem = (ULONG_PTR)pDPA_GetPtr(dpa, i++); if(!ulItem) break; dwOut = dwOut << 4 | (ulItem & 0xf); } *pdwOut = dwOut; if(dwOut != dwIn) { pDPA_DeleteAllPtrs(dpa); do { pDPA_InsertPtr(dpa, 0, (PVOID)(ULONG_PTR)(dwIn & 0xf)); dwIn >>= 4; } while(dwIn); return FALSE; }
/************************************************************************* * SIC_Destroy * * frees the cache */ void SIC_Destroy(void) { LPSIC_ENTRY lpsice; int i; TRACE("\n"); EnterCriticalSection(&SHELL32_SicCS); if (sic_hdpa && NULL != pDPA_GetPtr (sic_hdpa, 0)) { for (i=0; i < pDPA_GetPtrCount(sic_hdpa); ++i) { lpsice = pDPA_GetPtr(sic_hdpa, i); SHFree(lpsice); } pDPA_Destroy(sic_hdpa); } sic_hdpa = NULL; LeaveCriticalSection(&SHELL32_SicCS); DeleteCriticalSection(&SHELL32_SicCS); }