-
Hi,
All common files are linked to
programs and the programs have
icons. Now when you look at a
file and its linked to a program...
pic121.jpg --OpenIn-> Ie5
the picture will have the IE5
icon. Now my question is, I
need to know how to get that icon!
Thanks!
-
You can use the ExtractAssociatedIcon and DrawIconEx api functions.
Code:
Private Declare Function ExtractAssociatedIcon _
Lib "shell32.dll" Alias "ExtractAssociatedIconA" (ByVal _
hInst As Long, ByVal lpIconPath As String, lpiIcon As Long) _
As Long
Private Declare Function DrawIconEx Lib "user32" (ByVal hdc _
As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal _
hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As _
Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw _
As Long, ByVal diFlags As Long) As Long
Private Sub Command1_Click()
lIcon = ExtractAssociatedIcon(App.hInstance, "C:\Myfile.exe", -1) 'extract icon
Call DrawIconEx(Picture1.hdc, 0, 0, lIcon, 32, 32, 0, 0, 3) 'draw icon
End Sub