Need some help with the ExtractAssociatedIcon function,
When I use the function the return value is the handle of the associated icon, but it is in 32x32 format which causes the icon to be blurry when i use the DrawIconEx at 16x16 size.
Therefore I chosed to extract the 16x16 icon manually by using the path that GetAssociatedIcon is supposeed to receive (IconExe variable and IconIndex variable).
but the problem is that the function always receive the "c:\windows\system\shell32.dll" file?! instead of the actuall icon file. It causes the extracticonex to always receive the same icon.. why????
anyone have a solution?
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 ExtractIconEx Lib "shell32.dll" Alias "ExtractIconExA" (ByVal lpszFile As String, ByVal nIconIndex As Long, phiconLarge As Long, phiconSmall As Long, ByVal nIcons 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 Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
Const DI_MASK = &H1
Const DI_IMAGE = &H2
Const DI_NORMAL = DI_MASK Or DI_IMAGE
Const MAX_PATH = 260
Dim mIcon As Long
Dim IconExe As String
Dim IconIndex As Long
Dim glLargeIcons() As Long
Dim glSmallicons() As Long
Dim X As Integer
IconExe = "c:\myfile.txt"
IconExe = IconExe & Space(MAX_PATH - Len(IconExe))
IconIndex = 0
'Here is the problem, the fu**ing function doesn't work
mIcon = ExtractAssociatedIcon(App.hInstance, IconExe, IconIndex)
Call ExtractIconEx(IconExe, IconIndex, glLargeIcons(0), glSmallicons(0), 1)
DrawIconEx Picture1.hdc, 0, 0, glSmallicons(0), 16, 16, 0, 0, DI_NORMAL
For X = 0 To UBound(glLargeIcons)