DelphiFAQ Home Search:

Extracting both the small and the large icon from a file

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

The Windows help files only document ExtractIcon which extracts the large icon from an EXE (DLL, etc.).

There is an undocumented function ExtractIconEx which retrieves both the small and the large icon as shown below.

procedure TForm1.FormPaint(Sender: TObject);
var
  LargeIcon: HIcon;
  SmallIcon: HIcon;
  IconCount: Integer;
  i: Integer;
  FileName: PChar;
begin
  // draw a stripe with all large icons contained in the file
  // and below of that a stripe with all small icons.

  FileName := 'C:\WinNT\RegEdit.exe';
  IconCount := ExtractIconEx(FileName, -1, LargeIcon, SmallIcon, 0);
  for i := 0 to Pred(IconCount) do
  begin
    ExtractIconEx(FileName, i, LargeIcon, SmallIcon, 1);
    DrawIcon(Canvas.Handle, 5 + i * 36, 5, LargeIcon);
    DrawIconEx(Canvas.Handle, 5 + i * 36, 50, SmallIcon,
      GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
  end;
end;


Comments:

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Washington, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.