ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Saving application ICON

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
bmesser Posted - Oct 14 2025 : 10:37:23
Hi

This is not strictly an ImageEN issue but I can't find anyone who has cracked it after extensive searching of the internet about it.

I want to capture the ICON of an application.

I can do this by calling SHGetFileInfo, and then converting the returned ICO into a BMP.

This works fine, but I lose the transparency.

How can I do it and save it as a regular ICON?

Bruce.


function TfmMain.GetApplicationICON(path: string): TIcon;
var
  Icon     : TIcon;
  FileInfo : SHFILEINFO;
begin
  Icon:=TIcon.Create;

  try
    //Get the DisplayName
    SHGetFileInfo(PChar(path),0,FileInfo,SizeOf(FileInfo),SHGFI_DISPLAYNAME);
    // Get the TypeName
    SHGetFileInfo(PChar(path),0,FileInfo,SizeOf(FileInfo),SHGFI_TYPENAME);
    // Get the applicatiion ICON
    SHGetFileInfo(PChar(path),0,FileInfo,SizeOf(FileInfo),SHGFI_ICON or SHGFI_LARGEICON);

    Icon.Handle:=FileInfo.hIcon;
    result:=Icon;

    //result:=TBitMap.Create;
    //result.Height:=Icon.Height;
    //result.Width:=Icon.Width;
    //result.Canvas.Draw(0,0,Icon);

    DestroyIcon(FileInfo.hIcon);
  finally
    Icon.Free;
  end;
end;
2   L A T E S T    R E P L I E S    (Newest First)
bmesser Posted - Oct 14 2025 : 15:02:14
Thanks Nigel, will do!
xequte Posted - Oct 14 2025 : 14:47:15
Hi Bruce

Look at the IEGetFileIcon() method in our bmpfilt.pas unit, which will show you how to get it into a TIEBitmap with transparency.

To output it as a 32bit BMP see the example at:

http://www.imageen.com/help/TIEBitmap.SynchronizeRGBA.html

Nigel
Xequte Software
www.imageen.com