Board index » delphi » HELPME - Extracting Icons from an EXE-File ?

HELPME - Extracting Icons from an EXE-File ?

Hello,

I've a big problem (no - really?:-). I want to extract an icon from an
executable Windows-Application and store it in a TIcon or TBitmap
object. I have thought of using ExtractIcon (WINAPI) or something, but
maybe I'm too stupid to use it for solving my problem. Perhaps some of
you have had the same problem, too, and can provide a solution or a
source of information (I think WINAPI.HLP is not the best one...).
PLEASE help me if you can, and if possible, send me a mail because I
cannot read this Newsgroup very often.

Thanx a LOT
Rene

 

Re:HELPME - Extracting Icons from an EXE-File ?


Quote
Ren Gielen wrote:

> Hello,

> I've a big problem (no - really?:-). I want to extract an icon from an
> executable Windows-Application and store it in a TIcon or TBitmap
> object. I have thought of using ExtractIcon (WINAPI) or something,

        At least in win3.1/D1 you can easily use ExtractIcon for this;
I imagine it's the same in D2 but I never tried it. What you maybe
don't realize is that a Delphi TIcon's handle is not readonly (surprised
me when someone pointed this out...)
        So for example you could use ExtractIcon to obtain a Windows
HICON from an exe. Then you could Create a TIcon, say

theTIcon.Handle := theHICON;

and then use theTIcon.SaveToFile or theTIcon.Whatever.

--
David Ullrich
Sig file accidentally deleted - sorry.

Re:HELPME - Extracting Icons from an EXE-File ?


Quote
Ren Gielen wrote:

 > Hello,
 >
 > I've a big problem (no - really?:-). I want to extract an icon from
an
 > executable Windows-Application and store it in a TIcon or TBitmap
 > object. I have thought of using ExtractIcon (WINAPI) or something,
but
 > maybe I'm too stupid to use it for solving my problem. Perhaps some
of
 > you have had the same problem, too, and can provide a solution or a
 > source of information (I think WINAPI.HLP is not the best one...).
 > PLEASE help me if you can, and if possible, send me a mail because I
 > cannot read this Newsgroup very often.
 >
 > Thanx a LOT
 > Rene

Ren,

There are a couple of ways you could go here.  There are Windows API
functions called LoadIcon and LoadBitmap, look them up in help.  The are
also VCL classes, TIcon and TBitmap, which have LoadFromFile methods.
These should be in the help under the class names.

This should get you started,

-Tim.

Re:HELPME - Extracting Icons from an EXE-File ?


Quote
In article <31BC4E1B.4...@vaire.imib.rwth-aachen.de>, Ren Gielen <r...@imib.rwth-aachen.de> writes:
>Hello,

>I've a big problem (no - really?:-). I want to extract an icon from an
>executable Windows-Application and store it in a TIcon or TBitmap
>object. I have thought of using ExtractIcon (WINAPI) or something, but
>maybe I'm too stupid to use it for solving my problem. Perhaps some of
>you have had the same problem, too, and can provide a solution or a
>source of information (I think WINAPI.HLP is not the best one...).
>PLEASE help me if you can, and if possible, send me a mail because I
>cannot read this Newsgroup very often.

>Thanx a LOT
>Rene

Try something like this:

var
  TheIcon : TIcon ;

begin
  TheIcon := TIcon.Create ;
  TheIcon.Handle := ExtractIcon( Application.Handle, 'PROGNAME.EXE', 1 ) ;

  { ... do stuff with TheIcon ... }

  TheIcon.Free ;
end ;

HTH

-* Stephen *-
Stephen Posey
University of New Orleans
Email  : S...@uno.edu
WWW    : http://www.uno.edu/~slp

Other Threads