Delphi Shell IExtractIcon usage and result

Posted by Roy M Klever on Stack Overflow See other posts from Stack Overflow or by Roy M Klever
Published on 2010-06-13T13:44:45Z Indexed on 2010/06/13 13:52 UTC
Read the original article Hit count: 363

Filed under:
|
|
|

What I do: Try to extract thumbnail using IExtractImage if that fail I try to extract icons using IExtractIcon, to get maximum iconsize, but IExtractIcon gives strange results. Problem is I tried to use a methode that extracts icons from an imagelist but if there is no large icon (256x256) it will render the smaller icon at the topleft position of the icon and that does not look good. That is why I am trying to use the IExtractIcon instead. But icons that show up as 256x256 icons in my imagelist extraction methode reports icon sizes as 33 large and 16 small. So how do I check if a large (256x256) icon exists? If you need more info I can provide som sample code.

if PThumb.Image = nil then
begin
  OleCheck(ShellFolder.ParseDisplayName(0, nil, StringToOleStr(PThumb.Name), Eaten, PIDL, Atribute));
  ShellFolder.GetUIObjectOf(0, 1, PIDL, IExtractIcon, nil, XtractIcon);
  CoTaskMemFree(PIDL);
  bool:= False;
  if Assigned(XtractIcon) then
  begin
    GetLocationRes := XtractIcon.GetIconLocation(GIL_FORSHELL, @Buf, sizeof(Buf), IIdx, IFlags);
    if (GetLocationRes = NOERROR) or (GetLocationRes = E_PENDING) then
    begin
      Bmp := TBitmap.Create;
      try
        OleCheck(XtractIcon.Extract(@Buf, IIdx, LIcon, SIcon, 32 + (16 shl 16)));
        Done:= False;

Roy M Klever

© Stack Overflow or respective owner

Related posts about delphi

Related posts about shell