1 Private Const MAX_PATH = 260
2 Private Const SHGFI_DISPLAYNAME = &H200 ' get display name
3 Private Const SHGFI_EXETYPE = &H2000 ' return exe type
4 Private Const SHGFI_LARGEICON = &H0 ' get large icon
5 Private Const SHGFI_SHELLICONSIZE = &H4 ' get shell size icon
6 Private Const SHGFI_SMALLICON = &H1 ' get small icon
7 Private Const SHGFI_SYSICONINDEX = &H4000 ' get system icondex
8 Private Const SHGFI_TYPENAME = &H400 ' get type name
9 Private Const ILD_BLEND50 = &H4
10 Private Const ILD_BLEND25 = &H2
11 Private Const ILD_TRANSPARENT = &H1
12 Private Const CLR_NONE = &HFFFFFFFF
13 Private Const CLR_DEFAULT = &HFF000000
14 Private Type SHFILEINFO
15 hIcon As Long
16 iIcon As Long
17 dwAttributes As Long
18 szDisplayName As String * MAX_PATH
19 szTypeName As String * 80
20 End Type
21 Private Declare Function SHGetFileInfo Lib "shell32.dll" Alias "SHGetFileInfoA" (ByVal pszPath As String, ByVal dwFileAttributes As Long, psfi As SHFILEINFO, ByVal cbFileInfo As Long, ByVal uFlags As Long) As Long
22 Private Declare Function ImageList_Draw Lib "comctl32.dll" (ByVal himl As Long, ByVal i As Long, ByVal hdcDst As Long, ByVal x As Long, ByVal y As Long, ByVal fStyle As Long) As Long
23 Private Declare Function ImageList_DrawEx Lib "comctl32.dll" (ByVal himl As Long, ByVal i As Long, ByVal hdcDst As Long, ByVal x As Long, ByVal y As Long, ByVal dx As Long, ByVal dy As Long, ByVal rgbBk As Long, ByVal rgbFg As Long, ByVal fStyle As Long) As Long
24
25
26 Private Sub Form_Load()
27 Dim hImage As Long, udtFI As SHFILEINFO
28 Me.AutoRedraw = True
29 hImage = SHGetFileInfo("C:\Program Files\Windows Media Player\wmplayer.exe", ByVal 0&, udtFI, Len(udtFI), SHGFI_SYSICONINDEX Or SHGFI_LARGEICON)
30 ImageList_Draw hImage, udtFI.iIcon, Me.hDC, 0, 0, ILD_TRANSPARENT
31 ImageList_DrawEx hImage, udtFI.iIcon, Me.hDC, 32, 0, 32, 32, CLR_NONE, CLR_DEFAULT, ILD_BLEND50
32 End Sub
33
2 Private Const SHGFI_DISPLAYNAME = &H200 ' get display name
3 Private Const SHGFI_EXETYPE = &H2000 ' return exe type
4 Private Const SHGFI_LARGEICON = &H0 ' get large icon
5 Private Const SHGFI_SHELLICONSIZE = &H4 ' get shell size icon
6 Private Const SHGFI_SMALLICON = &H1 ' get small icon
7 Private Const SHGFI_SYSICONINDEX = &H4000 ' get system icondex
8 Private Const SHGFI_TYPENAME = &H400 ' get type name
9 Private Const ILD_BLEND50 = &H4
10 Private Const ILD_BLEND25 = &H2
11 Private Const ILD_TRANSPARENT = &H1
12 Private Const CLR_NONE = &HFFFFFFFF
13 Private Const CLR_DEFAULT = &HFF000000
14 Private Type SHFILEINFO
15 hIcon As Long
16 iIcon As Long
17 dwAttributes As Long
18 szDisplayName As String * MAX_PATH
19 szTypeName As String * 80
20 End Type
21 Private Declare Function SHGetFileInfo Lib "shell32.dll" Alias "SHGetFileInfoA" (ByVal pszPath As String, ByVal dwFileAttributes As Long, psfi As SHFILEINFO, ByVal cbFileInfo As Long, ByVal uFlags As Long) As Long
22 Private Declare Function ImageList_Draw Lib "comctl32.dll" (ByVal himl As Long, ByVal i As Long, ByVal hdcDst As Long, ByVal x As Long, ByVal y As Long, ByVal fStyle As Long) As Long
23 Private Declare Function ImageList_DrawEx Lib "comctl32.dll" (ByVal himl As Long, ByVal i As Long, ByVal hdcDst As Long, ByVal x As Long, ByVal y As Long, ByVal dx As Long, ByVal dy As Long, ByVal rgbBk As Long, ByVal rgbFg As Long, ByVal fStyle As Long) As Long
24
25
26 Private Sub Form_Load()
27 Dim hImage As Long, udtFI As SHFILEINFO
28 Me.AutoRedraw = True
29 hImage = SHGetFileInfo("C:\Program Files\Windows Media Player\wmplayer.exe", ByVal 0&, udtFI, Len(udtFI), SHGFI_SYSICONINDEX Or SHGFI_LARGEICON)
30 ImageList_Draw hImage, udtFI.iIcon, Me.hDC, 0, 0, ILD_TRANSPARENT
31 ImageList_DrawEx hImage, udtFI.iIcon, Me.hDC, 32, 0, 32, 32, CLR_NONE, CLR_DEFAULT, ILD_BLEND50
32 End Sub
33