Delphi extracts EXE and DLL file icons

Source: Internet
Author: User

// 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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.