Hello,
I use the API ExtractIcon to get icon from Shell32, but the returned icon
lost alpha channel, how get back the alpha channel? thank you.
************************************************** ********************************************
Private Declare Function ExtractIconEx Lib "shell32.dll" Alias
"ExtractIconExA" (ByVal lpszFile As String, ByVal nIconIndex As Int32, ByRef
phiconLarge As Int32, ByRef phiconSmall As Int32, ByVal nIcons As Int32) As
Int32
Private Declare Function DestroyIcon Lib "user32.dll" (ByVal hIcon As
Int32) As Int32
Function getIconFromFilename(ByVal filename As String, ByVal iconIndex
As Int16, ByVal largeIcon As Boolean) As Bitmap
Dim iconLarge As Int32
Dim iconSmall As Int32
If (ExtractIconEx(filename, iconIndex, iconLarge, iconSmall, 1) > 0)
Then
Dim iconPtr As IntPtr
If largeIcon = True Then
iconPtr = New IntPtr(iconLarge)
Else
iconPtr = New IntPtr(iconSmall)
End If
Dim iconRes As Icon = Icon.FromHandle(iconPtr)
Dim returnBitmap As Bitmap = iconRes.ToBitmap
iconRes.Dispose()
If iconLarge <> 0 Then DestroyIcon(iconLarge)
If iconSmall <> 0 Then DestroyIcon(iconSmall)
Return returnBitmap
Else
Return Nothing
End If
End Function