Troy,
I have a routine that uses ExtractIcon. You could modify it to use
ExtractAssociatedIcon with little difficulty.
'============================================
'CODE BEGINS HERE
'============================================
Private Type PICDEST_TYPE
lSize As Long
lType As Long
hBMP As Long
hPal As Long
hNonBMPObj As Long
End Type
Private Type GUID_TYPE
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA"
( _
ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As
Long) As Long
Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" ( _
PicDesc As PICDEST_TYPE, RefIID As GUID_TYPE, ByVal fPictureOwnsHandle&,
_
IPic As IPictureDisp) As Long
Public Function GetModuleIcon(ByVal sModule As String) As IPictureDisp
Dim llhIcon As Long
Dim lobjPic As IPicture
Dim ltGUID As GUID_TYPE
Dim ltPicDest As PICDEST_TYPE
On Error Resume Next
With ltGUID
.Data1 = &H20400
.Data4(0) = &HC0
.Data4(7) = &H46
End With
With ltPicDest
.lSize = Len(ltPicDest)
.lType = vbPicTypeIcon
End With
Set GetModuleIcon = LoadResPicture(14001, vbResIcon) 'default icon for my
app
If Len(Dir$(sModule)) Then
sModule = sModule & Chr$(0)
llhIcon = ExtractIcon(App.hInstance, sModule, 0&)
If llhIcon > 1 Then
ltPicDest.hBMP = llhIcon
If OleCreatePictureIndirect(ltPicDest, ltGUID, 1, lobjPic) = 0 Then
Set GetModuleIcon = lobjPic
End If
Call DeleteObject(llhIcon)
End If
End If
End Function
'============================================
END CODE
'============================================
>Does anyone have any sample code that shows how to get the icon represented
>by the handle returned by the ExtractAssociatedIcon() function into a
>picture object or image list? Or, for that matter, sample code that
>demonstrates how to use ExtractAssociatedIcon (or ExtractIcon) in VB?
>TIA,
>Troy Young
> Ventana Corporation