Mega Code Archive

 
Categories / Delphi / Files
 

Extract icon of file

Title: Extract icon of file Use ExtractAssociatedIcon for getting Handle of the icon. And use this result for Draw method of Canvas. procedure TForm1.Button1Click(Sender: TObject); begin if OpenDialog1.Execute then Edit1.Text:=OpenDialog1.FileName; end; procedure TForm1.Button2Click(Sender: TObject); var MyIcon: TIcon; Filter: Word; begin Filter:=0; MyIcon:=TIcon.Create; MyIcon.Handle:=ExtractAssociatedIcon( hInstance, PChar(Edit1.Text), Filter); Image1.Canvas.Draw(0, 0, MyIcon); end;