?
Solved

How I can  get Small Icon from a file?

Posted on 2001-08-05
7
Medium Priority
?
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:
Mohammed Nasman earned 400 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

770 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