[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How I can  get Small Icon from a file?

Posted on 2001-08-05
7
Medium Priority
?
198 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

656 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