Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to extract the associated icon of an application Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
22-Mar-03
Category
Shell API
Language
Delphi 2.x
Views
113
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius 

In my program, I am displaying a set of path and file names on the screen as the 
user choses them using a TList box. Alongside this list box I would like to display 
the icon associated with each one (if available). I understand that some icons are 
embedded in the executable and others are associated by Windows. Can you point me 
in the right direction for determining what the icon is, programmatically 
extracting it and placing it into an image array.

Answer:
1   
2   procedure TForm1.Button1Click(Sender: TObject);
3   var
4     HIcon: THandle;
5     iIcon: Word;
6     FilePath: array[0..MAX_PATH] of Char;
7   begin
8     if OpenDialog1.Execute then
9     begin
10      Label1.Caption := OpenDialog1.FileName;
11      Label1.Repaint;
12      StrPCopy(FilePath, OpenDialog1.FileName);
13      HIcon := ExtractAssociatedIcon(Application.Handle, @FilePath[0], iIcon);
14      if HIcon <> 0 then
15        Image1.Picture.Icon.Handle := HIcon;
16    end;
17  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC