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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Saving application ICON
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

bmesser

United Kingdom
246 Posts

Posted - Oct 14 2025 :  10:37:23  Show Profile  Reply
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;

xequte

39223 Posts

Posted - Oct 14 2025 :  14:47:15  Show Profile  Reply
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
Go to Top of Page

bmesser

United Kingdom
246 Posts

Posted - Oct 14 2025 :  15:02:14  Show Profile  Reply
Thanks Nigel, will do!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: