The fastest way to get a shell icon

I use this code to get a shell icon (the one that appears in Windows Explorer).
Anyone have experience with a faster way to get these badges? SHGetFileInfo seems rather slow.

 procedure TForm2.Button1Click(Sender: TObject); var FileInfo: TSHFileInfo; begin FillChar(FileInfo, SizeOf(FileInfo), 0); if SHGetFileInfo(PChar('c:\windows\'), 0, FileInfo, SizeOf(FileInfo), SHGFI_ICON or SHGFI_SMALLICON or SHGFI_SYSICONINDEX) <> 0 then DrawIconEx(Canvas.Handle, 10, 10, FileInfo.hIcon, 0, 16, 16, 0, DI_IMAGE or DI_MASK); end; 

Thanks!

+7
source share
2 answers
+8
source

I used the cache when I used SHGetFileInfo. If it is a .exe or .ico file (and possibly several more), the icon will be the same for the same file extension, so when you show the dir list, you can use the same icon for files of the same type, and you do not need to call (and wait) SHGetFileInfo again.

+3
source

All Articles