i want to extract icon from exe file.
does anyone know how to do this??
thank you very much
Regards
Estella
i want to extract icon from exe file.
does anyone know how to do this??
thank you very much
Regards
Estella
declared on module...
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
Private Type SHFILEINFO
hIcon As Long: iIcon As Long: dwAttributes As Long: szDisplayName As String * MAX_PATH: szTypeName As String * 80
End Type
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
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
Private shinfo As SHFILEINFO, sshinfo As SHFILEINFO
Public Enum IconRetrieve
ricnLarge = 32
ricnSmall = 16
End Enum
Add in your declaration :
Const MAX_PATH As Integer = 260
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?
add this following code in your module :
Public Sub RetrieveIcon(fName As String, DC As PictureBox, icnSize As IconRetrieve)
Dim hImgSmall, hImgLarge As Long 'the handle to the system image list
DC.Cls
Select Case icnSize
Case ricnSmall
hImgSmall = SHGetFileInfo(fName$, 0&, shinfo, Len(shinfo), BASIC_SHGFI_FLAGS Or SHGFI_SMALLICON)
Call ImageList_Draw(hImgSmall, shinfo.iIcon, DC.hDC, 0, 0, ILD_TRANSPARENT)
Case ricnLarge
hImgLarge& = SHGetFileInfo(fName$, 0&, shinfo, Len(shinfo), BASIC_SHGFI_FLAGS Or SHGFI_LARGEICON)
Call ImageList_Draw(hImgLarge, shinfo.iIcon, DC.hDC, 0, 0, ILD_TRANSPARENT)
End Select
End Sub
this function will called like this :
RetrieveIcon lblPath.Caption, PicIcon32, ricnLarge
PicIcon32 is picturebox
hope this helps...
yes, got it.
Working like a charm.
RetrieveIcon "C:\Program Files\Winamp\winamp.exe", PicIcon32, ricnLarge
Thank you very much
btw if i want to see the small one, i use bellow code :
RetrieveIcon "C:\Program Files\Winamp\winamp.exe", PicIcon32, ricnSmall
That right jx??
yes, thats right...
Ok. Thanks again.
you really help me much with great code.
This thread already solved.
you're Welcome...
Happy coding Friend :)
hello every one,
how to extract .exe files using vb 6.0. any one pls help me out
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.