forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Icon extraction

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Tdk161
Valued Contributor
Valued Contributor


Joined: 08 Feb 2005
Posts: 399
Location: ITALY

PostPosted: Wed Feb 20, 2008 9:15 am    Post subject: Icon extraction Reply with quote

Hi guyz

I need to extract an icon from exe

It's possible with vds6?

If yes How?

Many tnx
Back to top
View user's profile Send private message Send e-mail
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 656
Location: Eastern Indiana

PostPosted: Thu Feb 21, 2008 11:13 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Thu Feb 21, 2008 11:59 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Hooligan
VDS Developer
VDS Developer


Joined: 28 Oct 2003
Posts: 480
Location: California

PostPosted: Fri Feb 22, 2008 12:03 am    Post subject: Reply with quote

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
View user's profile Send private message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Fri Feb 22, 2008 10:25 pm    Post subject: Reply with quote

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
View user's profile Send private message
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Sat Feb 23, 2008 1:30 am    Post subject: Reply with quote

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
View user's profile Send private message
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Sat Feb 23, 2008 10:53 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Tdk161
Valued Contributor
Valued Contributor


Joined: 08 Feb 2005
Posts: 399
Location: ITALY

PostPosted: Tue Feb 26, 2008 7:50 am    Post subject: Reply with quote

[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 Smile
I need to extract the icon to use in a my prg

Many tnx to all for post
Back to top
View user's profile Send private message Send e-mail
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Tue Feb 26, 2008 9:07 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Tdk161
Valued Contributor
Valued Contributor


Joined: 08 Feb 2005
Posts: 399
Location: ITALY

PostPosted: Tue Feb 26, 2008 2:53 pm    Post subject: Reply with quote

Thanks Shinobi, and I need to save the icon extracted
Back to top
View user's profile Send private message Send e-mail
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Thu Feb 28, 2008 5:00 am    Post subject: Reply with quote

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. Smile

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Tdk161
Valued Contributor
Valued Contributor


Joined: 08 Feb 2005
Posts: 399
Location: ITALY

PostPosted: Sat Mar 15, 2008 11:26 am    Post subject: Reply with quote

Hi Shinobi Smile

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
View user's profile Send private message Send e-mail
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1753
Location: Space and Time

PostPosted: Sat May 03, 2008 2:54 pm    Post subject: Reply with quote

I want to do the same thing .I did a search and found a freeware command line utility to get the icons. Here is the info and DL.

http://www.snapfiles.com/get/batchiconex.html

_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group