// Uses shellapi
Procedure tform1.button1click (Sender: tobject );
VaR
Iconindex: word;
H: hicon;
Begin
Iconindex: = 0;
H: = extracticon (hinstance, pchar ('C: "Windows" notepad.exe '), iconindex );
Drawicon (form1.canvas. Handle, 200,100, H );
End;
// Use the imagelist control to save the extracted icon and display it in listview.
Ficon. Handle: = hicon1;
Imagelist1.addicon (ficon );
Listitem: = listview1.items. Add;
Listitem. imageindex: = imagelist1.count-1;
End;
========================================================== ================
Use shellapi; // extract the icon and assign it to SpeedButton. glyph
Procedure tform1.button1click (Sender: tobject );
VaR
HC: ticon;
Bitmap: tbitmap;
Begin
// Open the EXE
Opendialog1.execute;
HC: = ticon. Create;
Bitmap: = tbitmap. Create;
// Extract the EXE icon
HC. Handle: = extracticon (hinstance, pchar (opendialog1.filename), 0 );
// Convert the obtained ICO to bitmap
Bitmap. Width: = HC. width;
Bitmap. Height: = HC. height;
Bitmap. Canvas. Draw (0, 0, HC );
// Pass bitmap to SpeedButton. glyph
Speedbutton1.glyph: = bitmap;
// Release resources
HC. Free;
Bitmap. Free;
End;