//statement:
ExtractIcon (
  hInst: HINST;            {program instance calling function}
  lpszExeFileName: PChar; {file path; file can be * .exe, * .dll, * .ico}
  nIconIndex: UINT         {icon index}
): HICON; {return the icon handle; return the first icon handle when index is 0; return the total number of icons when index is #FFFFFFFF


// Example:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type 
  TForm1 =class (TForm)
    Button1: TButton;
    procedure Button1Click (Sender: TObject);
  end ;

var
  Form1: TForm1;

implementation

{$ R * .dfm}

uses ShellAPI; {ExtractIcon declared in it}

procedure TForm1.Button1Click (Sender: TObject);
var
  ico: TIcon;
  i, count, x, y, w, h: Integer;
  FilePath: string ;
begin
   {just find a path, if it is missing, you will exit}
  FilePath: = 'C: \ Program Files \ Macromedia \ Fireworks 8 \ Fireworks.exe';
  if not FileExists (FilePath)then begin ShowMessage ('file does not exist'); Exit; end ;

  ico: = TIcon.Create;
  x: = 10; y: = 10; w: = 0; h: = 0;
  Repaint;

  {First calculate the total number of icons in the file}
  count: = ExtractIcon (HInstance, PChar (FilePath), HICON (-1));

  for i: =0 to count-1 do
  begin
     {loop extraction icon}
    ico.Handle: = ExtractIcon (HInstance, PChar (FilePath), i);

    {Draw the icon}
    Canvas.Draw (x, y, ico);

    {Just adjust the display position below}
    if w <ico.Widththen w: = ico.Width;
    if h <ico.Heightthen h: = ico.Height;
    x: = x + ico.Width + 10;
    if x> = ClientWidth-wthen
    begin 
      x: =10;
      y: = y + h + 10;
    end ;
  end ;

  ico.Free;
end ;

end .