943,690 Members | Top Members by Rank

Ad:
Apr 21st, 2008
0

Retrieve Icon From Exe File

Expand Post »
i want to extract icon from exe file.
does anyone know how to do this??

thank you very much

Regards
Estella
Similar Threads
Reputation Points: 37
Solved Threads: 7
Junior Poster in Training
Estella is offline Offline
99 posts
since Jan 2008
Apr 21st, 2008
4

Re: Retrieve Icon From Exe File

declared on module...
vb Syntax (Toggle Plain Text)
  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.
Reputation Points: 37
Solved Threads: 7
Junior Poster in Training
Estella is offline Offline
99 posts
since Jan 2008
Apr 21st, 2008
3

Re: Retrieve Icon From Exe File

Add in your declaration :
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Const MAX_PATH As Integer = 260
Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,138 posts
since Nov 2007
Apr 22nd, 2008
0

Re: Retrieve Icon From Exe File

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?
Reputation Points: 37
Solved Threads: 7
Junior Poster in Training
Estella is offline Offline
99 posts
since Jan 2008
Apr 22nd, 2008
4

Re: Retrieve Icon From Exe File

add this following code in your module :
vb Syntax (Toggle Plain Text)
  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...
Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,138 posts
since Nov 2007
Apr 22nd, 2008
0

Re: Retrieve Icon From Exe File

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
Reputation Points: 37
Solved Threads: 7
Junior Poster in Training
Estella is offline Offline
99 posts
since Jan 2008
Apr 22nd, 2008
0

Re: Retrieve Icon From Exe File

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??
Reputation Points: 37
Solved Threads: 7
Junior Poster in Training
Estella is offline Offline
99 posts
since Jan 2008
Apr 22nd, 2008
1

Re: Retrieve Icon From Exe File

yes, thats right...
Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,138 posts
since Nov 2007
Apr 22nd, 2008
0

Re: Retrieve Icon From Exe File

Ok. Thanks again.
you really help me much with great code.
This thread already solved.
Reputation Points: 37
Solved Threads: 7
Junior Poster in Training
Estella is offline Offline
99 posts
since Jan 2008
Apr 22nd, 2008
0

Re: Retrieve Icon From Exe File

you're Welcome...
Happy coding Friend
Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,138 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Need Help Creating A Macro
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: VB app that opens two CSV file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC