CodeItBetter Programming Another VB Programming Blog

How to Extract Icon from file

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'Graphics - How to Extract Icon from file

Option Explicit
 
'Add a Picture Box to your form and set Picture Box AutoRedraw property to True.

Public Const DI_MASK = &H1
Public Const DI_IMAGE = &H2
Public Const DI_NORMAL = DI_MASK Or DI_IMAGE
Declare Function ExtractAssociatedIcon Lib "shell32.dll" Alias "ExtractAssociatedIconA" _
    (ByVal hInst As Long, ByVal lpIconPath As String, lpiIcon As Long) As Long
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
Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
 
Private Sub Form_Load()
    mIcon = ExtractAssociatedIcon(App.hInstance, "C:\Test.txt", 2)
    DrawIconEx Picture1.hdc, 0, 0, mIcon, 0, 0, 0, 0, DI_NORMAL
    Call DestroyIcon(mIcon)
End Sub
Filed under: Graphics Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.