Images and Icons in EXE's, DLL's, and OCX's

Please could anyone tell me how I can load images and icons from an exe, dll, or an ocx file??
Is it possible to load them into my program and use them just like load in components in VB?. ^_^
KuosterAsked:
Who is Participating?
 
watyConnect With a Mentor Commented:
http://www.thescarms.com/VBasic/extracticons.htm
http://pc13.virtualave.net/files/Extract%20Icons%20from%20Files.zip

' #VBIDEUtils#************************************************************
' * Programmer Name  : Waty Thierry
' * Web Site         : www.geocities.com/ResearchTriangle/6311/
' * E-Mail           : waty.thierry@usa.net
' * Date             : 28/06/99
' * Time             : 12:46
' **********************************************************************
' * Comments         : Extract icons from EXE and DLL
' *
' *
' **********************************************************************

Public Const MAX_PATH = 260
Public Const SHGFI_DISPLAYNAME = &H200
Public Const SHGFI_EXETYPE = &H2000
Public Const SHGFI_SYSICONINDEX = &H4000 ' System icon index
Public Const SHGFI_LARGEICON = &H0 ' Large icon
Public Const SHGFI_SMALLICON = &H1 ' Small icon
Public Const ILD_TRANSPARENT = &H1 ' Display transparent
Public Const SHGFI_SHELLICONSIZE = &H4
Public Const SHGFI_TYPENAME = &H400
Public Const BASIC_SHGFI_FLAGS = SHGFI_TYPENAME _
   Or SHGFI_SHELLICONSIZE Or SHGFI_SYSICONINDEX _
   Or SHGFI_DISPLAYNAME Or SHGFI_EXETYPE
Public Type SHFILEINFO
   hIcon As Long
   iIcon As Long
   dwAttributes As Long
   szDisplayName As String * MAX_PATH
   szTypeName As String * 80
End Type

Public 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

Public Declare Function ImageList_Draw Lib "comctl32.dll" _
   (ByVal himl&, ByVal i&, ByVal hDCDest&, _
   ByVal x&, ByVal y&, ByVal flags&) As Long
Public shinfo As SHFILEINFO

Private Sub Command1_Click()
   Dim hImgSmall As Long ' The handle to the system image list
   Dim FileName As String ' The file name to get icon from
   Dim r As Long
   FileName$ = Text1.Text
   
   ' Get the system icons associated with the file
   hImgSmall& = SHGetFileInfo(FileName$, 0&, shinfo, Len(shinfo), _
      BASIC_SHGFI_FLAGS Or SHGFI_SMALLICON)
   
   hImgLarge& = SHGetFileInfo(FileName$, 0&, shinfo, Len(shinfo), _
      BASIC_SHGFI_FLAGS Or SHGFI_LARGEICON)
   
   ' Fill in the labels with the image's file data
   label1.Caption = Left$(shinfo.szDisplayName, _
      InStr(shinfo.szDisplayName, Chr$(0)) - 1)
   
   Label2.Caption = Left$(shinfo.szTypeName, _
      InStr(shinfo.szTypeName, Chr$(0)) - 1)
   
   ' Set the pictureboxes to receive the icons.
   Picture1.Picture = LoadPicture()
   Picture2.Picture = LoadPicture()
   
   ' Draw the associated icons into the picture boxes
   r& = ImageList_Draw(hImgSmall&, shinfo.iIcon, picSmall.hDC, 0, 0,_
      ILD_TRANSPARENT)
   r& = ImageList_Draw(hImgLarge&, shinfo.iIcon, picLarge.hDC, 0, 0,_
      ILD_TRANSPARENT)
End Sub


0
 
VbmasterCommented:
You can save and load images/icons into a VB app using a resource  file. Here's a MS article which explains the process with a sample project:
                    http://support.microsoft.com/support/kb/articles/Q194/4/09.ASP
0
 
KuosterAuthor Commented:
Does it work for EXE, DLL, and OCX files?
0
 
KuosterAuthor Commented:
Thanks very much for the answer! ^_^
0
All Courses

From novice to tech pro — start learning today.