Examples Delphi

USES
ShellAPI;
..
procedure ExtractIcon(IcoFileName: String);
VAR
IcoFileName : String;
IcoHandle : THandle;
MyIcon : TIcon;
BEGIN
// the last parameter is the index of the icon
IcoHandle := ExtractIcon(Application.Handle, PChar(IcoFilename), Word(0));
// is there an icon in this file?
IF IcoHandle = 0 then begin
ShowMessage('No icon in this file!');
exit;
END;
// okay, so there is an icon in this file
MyIcon := TIcon.Create;
MyIcon.Handle := IcoHandle;
// how much space are we going to need for the icon?
BitBtn1.Glyph.Height := MyIcon.Height;
BitBtn1.Glyph.Width := MyIcon.Width;
// now draw the icon on the button
BitBtn1.Glyph.Canvas.Draw(2, 2, MyIcon);
// lets draw it on a TImage too...
Image1.Picture.Icon := MyIcon;
// oh, starts to make fun .. lets change the applications icon too! ;-)
Application.Icon := MyIcon;
// free the icon
MyIcon.Free;
END;