| View previous topic :: View next topic |
| Author |
Message |
Tdk161 Valued Contributor


Joined: 08 Feb 2005 Posts: 399 Location: ITALY
|
Posted: Wed Feb 20, 2008 9:15 am Post subject: Icon extraction |
|
|
Hi guyz
I need to extract an icon from exe
It's possible with vds6?
If yes How?
Many tnx |
|
| Back to top |
|
 |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Thu Feb 21, 2008 11:13 pm Post subject: |
|
|
There is no way to do it with VDS unless someone has a way not posted at this forum, you have to use a third party program.
LINK is the only work around but with it you have to link to the EXE which is not extracting the icon, just using it with the shortcut. |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Thu Feb 21, 2008 11:59 pm Post subject: |
|
|
Hi Tdk161,
Are you needing to save the icon from another executable or just borrow
a copy of it to use in/with your program?
This can be done with the Windows API, but I need to know how you
intend to use the icon before I post any sample code. _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Fri Feb 22, 2008 12:03 am Post subject: |
|
|
Have you tried the ICOTOBMP command?
| Quote: | Syntax:
ICOTOBMP <output_bmp>, <input_ico> {, <index>, <16|32> }
Description:
Converts an icon (from an ICO, EXE or DLL file) to a 32x32 or 16x16 bitmap. This can be useful when you want to load an icon image into a dialog element that can only display bitmaps. The default <index> value is 0, which is the first icon in <input_ico> where this is a DLL or EXE file. The default size is 16x16.
|
Hope this helps...
Hooligan _________________ Hooligan
Why be normal? |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Fri Feb 22, 2008 10:25 pm Post subject: |
|
|
It is possible to extract an icon from an exe or dll using BINFILE. But you need to figure out where the icon starts and ends within the exe. I could be wrong through about this, but it just seems in my mind that it could be done.
I know there's some code somewhere around VDS World for at least determining if there's icon in exe. _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Sat Feb 23, 2008 1:30 am Post subject: |
|
|
| Garrett wrote: | | I know there's some code somewhere around VDS World for at least determining if there's icon in exe. |
Here's my user function to determine if a file contains an icon (though it's based on someone else's code that I found here).
| Code: | :HasIcon
#------------------------------------------------------------------
# Returns 1 if file contains an icon. SYNTAX %x = @HasIcon(<file>)
# OK is unchanged
#------------------------------------------------------------------
if @not(%1)
# Missing argument(s) to function
error 11
exit
end
# %1 = file
if @file(%1)
%c = 0
binfile open,1,%1,read
binfile seek,1,%c
repeat
%x = @binfile(read,1,text,32)
binfile seek,1,%c
if @greater(@pos("(...0...`....",%x),0)@greater(@pos("(... ...@....",%x),0)@greater(@pos("(....... ....",%x),0)
# If there is an icon, %x is set to 1, else it is null
%x = 1
else
%x =
end
%c = @sum(%c,16)
until @binfile(EOF,1) @not(@null(%x))
binfile close,1
else
# File or path does not exist
error 20
end
exit %x |
You'll need to define the function before using it, preferably near the top of your script.
| Code: | | #DEFINE FUNCTION, HasIcon |
_________________ cheers
Dave |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Sat Feb 23, 2008 10:53 am Post subject: |
|
|
| Garrett wrote: | | It is possible to extract an icon from an exe or dll... |
One note about icons stored within an executable. They are not stored in
the same format as found on your local hard drive as an icon file. _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
Tdk161 Valued Contributor


Joined: 08 Feb 2005 Posts: 399 Location: ITALY
|
Posted: Tue Feb 26, 2008 7:50 am Post subject: |
|
|
[quote="ShinobiSoft"]Hi Tdk161,
Are you needing to save the icon from another executable or just borrow
a copy of it to use in/with your program?
This can be done with the Windows API, but I need to know how you
intend to use the icon before I post any sample code.[/quote]
Hi Shinobi
I need to extract the icon to use in a my prg
Many tnx to all for post |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Tue Feb 26, 2008 9:07 am Post subject: |
|
|
The following code will allow you to load an Icon resource from another
executable module (.exe, .dll)
| Code: |
REM First load the library with LOADLIB. I'm going to use shell32.dll for this demo
LOADLIB shell32.dll
if @ok()
%%imgIndex = 0
REM Get an instance handle to the loaded dll
LOADLIB kernel32.dll
if @ok()
%%handle = @lib(user32.dll, GetModuleHandleA, INT:, STR: "shell32.dll")
FREELIB kernel32.dll
else
WARN Unable to load kernel32.dll
stop
end
if @greater(%%handle, 0)
REM Now there are two ways to load an icon from an executable
REM METHOD 1::: Uncomment the following to use
REM %%icon = @lib(user32.dll, LoadIconA, INT:, INT: %%handle, INT: %%imgIndex)
REM METHOD 2::: Uncomment the following to use
REM %%icon = @lib(user32.dll, LoadImageA, INT:, INT: %%handle, INT: #%%imgIndex, INT: 1, INT: 32, INT: 32, INT: 0)
if @greater(%%icon, 0)
REM We have a valid icon handle now.
REM Do something with this icon handle
REM We should alway free resources loaded from other executables
%z = @lib(user32.dll, DestroyIcon, INT:, INT: %%icon)
end
end
FREELIB shell32.dll
end
|
This code will only get the handle of an icon. It can be used with API's
like DrawIcon() and DraIconEx().
If you are needing to save the icon as a file on your hard disk, this will not
work. The process for doing that is much more complicated, but it can be
done in VDS 5 and up. I will post some code if this is what you want to do. _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
Tdk161 Valued Contributor


Joined: 08 Feb 2005 Posts: 399 Location: ITALY
|
Posted: Tue Feb 26, 2008 2:53 pm Post subject: |
|
|
| Thanks Shinobi, and I need to save the icon extracted |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Thu Feb 28, 2008 5:00 am Post subject: |
|
|
Hi Tdk161,
The best I can do for the moment is for you to download my Icon Browser
and use it to save the icon you need for your application. I have just
updated Icon Browser so that it can save icon resource to disk files.
It's a really involved process to work with binary resource data. I think
this would be more effecient at this time.  _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
Tdk161 Valued Contributor


Joined: 08 Feb 2005 Posts: 399 Location: ITALY
|
Posted: Sat Mar 15, 2008 11:26 am Post subject: |
|
|
Hi Shinobi
I'm making a software to create portable apps and for this reason i need to extract and icon from an exe files from my application, icon browser is a usefull utilitie but i can use it , I need to know how to estract icon and save by my prg
many thanks for your previous help |
|
| Back to top |
|
 |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1753 Location: Space and Time
|
|
| Back to top |
|
 |
|