下面的代码示范了一个完整的提取图标、存储图标的程序:
unit UFormIconGrabber;
interface
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, ShellAPI, ExtDlgs;
type
  TForm1 = class(TForm)
    Image1: TImage;
    btNextIcon: TButton;
    Label1: TLabel;
    EditFileName: TEdit;
    btBowserFile: TButton;
    OpenDialog1: TOpenDialog;
btSaveIco: TButton;
    SavePictureDialog1: TSavePictureDialog;
    btPrevirousIcon: TButton;
    procedure btNextIconClick(Sender: TObject);
    procedure btBowserFileClick(Sender: TObject);
    procedure btSaveIcoClick(Sender: TObject);
    procedure btPrevirousIconClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    Procedure MoveIconIndex(Const OperateString:String);
  end;
var
  Form1: TForm1;
implementation
{$ R *.DFM}
procedure TForm1.MoveIconIndex(Const OperateString:String);
const
 I : Integer = 0;
 FileName : String = '';
var
 Count : Integer;
begin
 if( FileName <> EditFileName.Text ) then
     begin
         FileName := EditFileName.Text;
         I := 0;
     end
 else
     if OperateString='MoveNextIcon' then
        Inc(I)
     else
        begin
            if I>0 then
               dec(I);
        end;
//得到总的图标数目
 Count := ExtractIcon( Application.Handle, PChar(FileName),$ FFFFFFFF);
 if( I < Count ) then
  Image1.Picture.Icon.Handle :=
   ExtractIcon( Application.Handle, PChar(FileName), I ) // I为图标的索引
 else
   ShowMessage('此文件没有更多的图标资源!' );
end;
procedure TForm1.btNextIconClick(Sender: TObject);
begin
 MoveIconIndex('MoveNextIcon');
end;
procedure TForm1.btBowserFileClick(Sender: TObject);
begin
     try
        OpenDialog1.Title:='选择EXE文件或DLL文件:';
        OpenDialog1.Filter:='提取文件(*.EXE;*.DLL;*.ICO)|*.DLL;*.EXE;*.ICO|All files (*.*)|*.*';
        OpenDialog1.FilterIndex:=1;
        if OpenDialog1.Execute then
           EditFileName.Text :=OpenDialog1.FileName;
        MoveIconIndex('MoveNextIcon');   
     except
        exit;
     end;
end;
procedure TForm1.btSaveIcoClick(Sender: TObject);
begin
     SavePictureDialog1.DefaultExt := GraphicExtension(TIcon);
     SavePictureDialog1.Filter := GraphicFilter(TIcon);
     if SavePictureDialog1.Execute then
        image1.Picture.SaveToFile(SavePictureDialog1.FileName);
end;
procedure TForm1.btPrevirousIconClick(Sender: TObject);
begin
    MoveIconIndex('MovePrevIcon');
end;
end.
但是被群中的心字灰说 ExtractIcon这个函数已经过时了,小草试过了,提取不了现代的图表组,或者透明的只能提取16*16和32×32两种
实验下再说