totok
asked on
How I can get Small Icon from a file?
Hi,
Just a quick question: How I can get Small Icon from a file?
I am using delphi 5.
Thank you for your help
Just a quick question: How I can get Small Icon from a file?
I am using delphi 5.
Thank you for your help
ExtractIconEx will return an array of small icons and another array of large icons.
use SHGetFileInfo API,FLAG use SHGFI_ICON.that is ok.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
but that will only extract one icon... some EXEs come with more than one.
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.
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.
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,BigImageLis t:TImageLi st;
implementation
{$R *.DFM}
procedure TForm1.FormActivate(Sender : TObject);
var
IconBig,IconSmall:HICON;
small,big:TIcon;
Iconnr,nr:integer;
hinst:THandle;
begin
SmallImageList:=TImageList .Create(se lf);SmallI mageList.H eight:=16; SmallImage List.Width :=16;
BigImageList:=TImageList.C reate(self );BigImage List.Heigh t:=32;BigI mageList.W idth:=32;
SmallListView:=TListView.C reate(self );
SmallListView.Parent:=Self ;
SmallListView.Align:=alLef t;
SmallListView.LargeImages: =SmallImag eList;
BigListView:=TListView.Cre ate(self);
BigListView.Parent:=Self;
BigListView.Align:=alClien t;
BigListView.LargeImages:=B igImageLis t;
small:=TIcon.Create;big:=T Icon.Creat e;
IconNr:=-1;
IconNr:=ExtractIconEx('c:\ windows\ex plorer.exe ',IconNr,I conBig,Ico nSmall,1);
for nr:=0 to IconNr-1 do begin
ExtractIconEx('c:\windows\ explorer.e xe',Nr,Ico nBig,IconS mall,1);
small.Handle:=IconSmall;
big.Handle:=IconBig;
SmallImageList.AddIcon(sma ll);BigIma geList.Add Icon(big);
SmallListView.Items.Add.Im ageIndex:= nr;
BigListView.Items.Add.Imag eIndex:=nr ;
end;
end;
end.
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:
SmallImageList,BigImageLis
implementation
{$R *.DFM}
procedure TForm1.FormActivate(Sender
var
IconBig,IconSmall:HICON;
small,big:TIcon;
Iconnr,nr:integer;
hinst:THandle;
begin
SmallImageList:=TImageList
BigImageList:=TImageList.C
SmallListView:=TListView.C
SmallListView.Parent:=Self
SmallListView.Align:=alLef
SmallListView.LargeImages:
BigListView:=TListView.Cre
BigListView.Parent:=Self;
BigListView.Align:=alClien
BigListView.LargeImages:=B
small:=TIcon.Create;big:=T
IconNr:=-1;
IconNr:=ExtractIconEx('c:\
for nr:=0 to IconNr-1 do begin
ExtractIconEx('c:\windows\
small.Handle:=IconSmall;
big.Handle:=IconBig;
SmallImageList.AddIcon(sma
SmallListView.Items.Add.Im
BigListView.Items.Add.Imag
end;
end;
end.
ASKER
Thank you, your code works great.