Solved

How I can  get Small Icon from a file?

Posted on 2001-08-05
7
187 Views
Last Modified: 2010-04-04
Hi,

Just a quick question: How I can get Small Icon from a file?

I am using delphi 5.

Thank you for your help
0
Comment
Question by:totok
7 Comments
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6354347
ExtractIconEx will return an array of small icons and another array of large icons.
0
 
LVL 1

Expert Comment

by:sundayboys
ID: 6354575
use SHGetFileInfo API,FLAG use SHGFI_ICON.that is ok.
0
 
LVL 22

Accepted Solution

by:
mnasman earned 100 total points
ID: 6354755
Hello

  you can extract the small icon from any kind from files(exe, bmp,...) with this code,

uses shellapi;
procedure TForm1.Button1Click(Sender: TObject);
var
  Info : TSHFileInfo;
  InfoSize : Integer;
begin
  InfoSize := SizeOf(TSHFileInfo);
  FillChar(Info, InfoSize, 0);
  SHGetFileInfo(PChar('c:\aa.exe'), 0, Info, InfoSize, SHGFI_ICON or SHGFI_SMALLICON);
  Image1.Picture.icon.Handle := Info.hIcon;
end;
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6354836
but that will only extract one icon... some EXEs come with more than one.
0
 
LVL 21

Expert Comment

by:gemarti
ID: 6355650
Take a look:
I found a demo program with delphi 5 & 6 that will extract Icons & Bitmaps from exe's and dlls!

[DELPHI$]\Demos\ResXplor"

Source Code is included.


0
 
LVL 1

Expert Comment

by:ntony
ID: 6359436
take a look at this (is more simple):



unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  comctrls, shellapi,extctrls;

type
  TForm1 = class(TForm)
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  SmallListView,BigListView:TListView;
  SmallImageList,BigImageList:TImageList;
implementation

{$R *.DFM}

procedure TForm1.FormActivate(Sender: TObject);
var
   IconBig,IconSmall:HICON;
   small,big:TIcon;
   Iconnr,nr:integer;
   hinst:THandle;
begin
     SmallImageList:=TImageList.Create(self);SmallImageList.Height:=16;SmallImageList.Width:=16;
     BigImageList:=TImageList.Create(self);BigImageList.Height:=32;BigImageList.Width:=32;

     SmallListView:=TListView.Create(self);
     SmallListView.Parent:=Self;
     SmallListView.Align:=alLeft;
     SmallListView.LargeImages:=SmallImageList;

     BigListView:=TListView.Create(self);
     BigListView.Parent:=Self;
     BigListView.Align:=alClient;
     BigListView.LargeImages:=BigImageList;

     small:=TIcon.Create;big:=TIcon.Create;

     IconNr:=-1;
     IconNr:=ExtractIconEx('c:\windows\explorer.exe',IconNr,IconBig,IconSmall,1);

     for nr:=0 to IconNr-1 do begin
         ExtractIconEx('c:\windows\explorer.exe',Nr,IconBig,IconSmall,1);
         small.Handle:=IconSmall;
         big.Handle:=IconBig;
         SmallImageList.AddIcon(small);BigImageList.AddIcon(big);
         SmallListView.Items.Add.ImageIndex:=nr;
         BigListView.Items.Add.ImageIndex:=nr;
     end;
end;

end.
0
 

Author Comment

by:totok
ID: 6359471
Thank you, your code works great.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now