Extract an icon from an Windows application and paint on a Form

Submitted by:David Villa

Date added:12 September, 2012

Category:Delphi

This tip shows how to extract the associated icon and draw it into a small area of the form (e.g. Notepad icon)

Tags: extract icon , draw icon

Code Snippet:

procedure TForm1.Button1Click(Sender: TObject) ;
var
IconIndex : word;
h : hIcon;
begin
IconIndex := 0;
h:=ExtractAssociatedIcon
(hInstance,'C:\WINDOWS\NOTEPAD.EXE', IconIndex) ;
DrawIcon(Form1.Canvas.Handle, 10, 10, h) ;
end;
 
 

Comments