unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ShellApi, Buttons, ExtCtrls;type
  TForm1 = class(TForm)
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    BitBtn1: TBitBtn;
    Image1: TImage;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
var
  IcoFileName: string;
  IcoHandle: THandle;
  MyIcon: TIcon;
begin
  if OpenDialog1.Execute then
  begin
    IcoFilename := OpenDialog1.FileName;
    IcoHandle := ExtractIcon(Application.Handle, PChar(IcoFilename), 0);
    if IcoHandle = 0 then
    begin
      ShowMessage('No Icon in this file');
      Exit;
    end;
    MyIcon := TIcon.Create;
    MyIcon.Handle := IcoHandle;
    BitBtn1.Glyph.Height := MyIcon.Height;
    BitBtn1.Glyph.Width := MyIcon.Width;
    BitBtn1.Glyph.Canvas.Draw(2, 2, MyIcon);
    Image1.Picture.Icon := MyIcon;
    Application.Icon := MyIcon;
    MyIcon.Free;
  end;
end;end.//注意要手工加入ShellApi;