Retrieve Icon From Exe File

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jan 2008
Posts: 97
Reputation: Estella is an unknown quantity at this point 
Solved Threads: 6
Estella's Avatar
Estella Estella is offline Offline
Junior Poster in Training

Retrieve Icon From Exe File

 
0
  #1
Apr 21st, 2008
i want to extract icon from exe file.
does anyone know how to do this??

thank you very much

Regards
Estella
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 97
Reputation: Estella is an unknown quantity at this point 
Solved Threads: 6
Estella's Avatar
Estella Estella is offline Offline
Junior Poster in Training

Re: Retrieve Icon From Exe File

 
2
  #2
Apr 21st, 2008
declared on module...
  1. Private Const SHGFI_DISPLAYNAME = &H200, SHGFI_EXETYPE = &H2000, SHGFI_SYSICONINDEX = &H4000, SHGFI_LARGEICON = &H0, SHGFI_SMALLICON = &H1, SHGFI_SHELLICONSIZE = &H4, SHGFI_TYPENAME = &H400, ILD_TRANSPARENT = &H1, BASIC_SHGFI_FLAGS = SHGFI_TYPENAME Or SHGFI_SHELLICONSIZE Or SHGFI_SYSICONINDEX Or SHGFI_DISPLAYNAME Or SHGFI_EXETYPE
  2. Private Type SHFILEINFO
  3. hIcon As Long: iIcon As Long: dwAttributes As Long: szDisplayName As String * MAX_PATH: szTypeName As String * 80
  4. End Type
  5. Private Declare Function SHGetFileInfo Lib "shell32.dll" Alias "SHGetFileInfoA" (ByVal pszPath As String, ByVal dwFileAttributes As Long, psfi As SHFILEINFO, ByVal cbSizeFileInfo As Long, ByVal uFlags As Long) As Long
  6. Private Declare Function ImageList_Draw Lib "Comctl32.dll" (ByVal himl As Long, ByVal i As Long, ByVal hDCDest As Long, ByVal X As Long, ByVal Y As Long, ByVal Flags As Long) As Long
  7. Private shinfo As SHFILEINFO, sshinfo As SHFILEINFO
  8.  
  9. Public Enum IconRetrieve
  10. ricnLarge = 32
  11. ricnSmall = 16
  12. End Enum
Last edited by Estella; Apr 21st, 2008 at 2:14 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Retrieve Icon From Exe File

 
1
  #3
Apr 21st, 2008
Add in your declaration :
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Const MAX_PATH As Integer = 260
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 97
Reputation: Estella is an unknown quantity at this point 
Solved Threads: 6
Estella's Avatar
Estella Estella is offline Offline
Junior Poster in Training

Re: Retrieve Icon From Exe File

 
0
  #4
Apr 22nd, 2008
thanks to completed my declaration.
actually i don't have idea to do this function.
do you know a function to retrieve icon from exe file using my delcaration?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Retrieve Icon From Exe File

 
4
  #5
Apr 22nd, 2008
add this following code in your module :
  1. Public Sub RetrieveIcon(fName As String, DC As PictureBox, icnSize As IconRetrieve)
  2. Dim hImgSmall, hImgLarge As Long 'the handle to the system image list
  3. DC.Cls
  4. Select Case icnSize
  5. Case ricnSmall
  6. hImgSmall = SHGetFileInfo(fName$, 0&, shinfo, Len(shinfo), BASIC_SHGFI_FLAGS Or SHGFI_SMALLICON)
  7. Call ImageList_Draw(hImgSmall, shinfo.iIcon, DC.hDC, 0, 0, ILD_TRANSPARENT)
  8. Case ricnLarge
  9. hImgLarge& = SHGetFileInfo(fName$, 0&, shinfo, Len(shinfo), BASIC_SHGFI_FLAGS Or SHGFI_LARGEICON)
  10. Call ImageList_Draw(hImgLarge, shinfo.iIcon, DC.hDC, 0, 0, ILD_TRANSPARENT)
  11. End Select
  12. End Sub
this function will called like this :
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. RetrieveIcon lblPath.Caption, PicIcon32, ricnLarge
PicIcon32 is picturebox

hope this helps...
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 97
Reputation: Estella is an unknown quantity at this point 
Solved Threads: 6
Estella's Avatar
Estella Estella is offline Offline
Junior Poster in Training

Re: Retrieve Icon From Exe File

 
0
  #6
Apr 22nd, 2008
yes, got it.
Working like a charm.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. RetrieveIcon "C:\Program Files\Winamp\winamp.exe", PicIcon32, ricnLarge

Thank you very much
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 97
Reputation: Estella is an unknown quantity at this point 
Solved Threads: 6
Estella's Avatar
Estella Estella is offline Offline
Junior Poster in Training

Re: Retrieve Icon From Exe File

 
0
  #7
Apr 22nd, 2008
btw if i want to see the small one, i use bellow code :
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. RetrieveIcon "C:\Program Files\Winamp\winamp.exe", PicIcon32, ricnSmall
That right jx??
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Retrieve Icon From Exe File

 
1
  #8
Apr 22nd, 2008
yes, thats right...
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 97
Reputation: Estella is an unknown quantity at this point 
Solved Threads: 6
Estella's Avatar
Estella Estella is offline Offline
Junior Poster in Training

Re: Retrieve Icon From Exe File

 
0
  #9
Apr 22nd, 2008
Ok. Thanks again.
you really help me much with great code.
This thread already solved.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Retrieve Icon From Exe File

 
0
  #10
Apr 22nd, 2008
you're Welcome...
Happy coding Friend
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC