Get Icon
Get Icon
' Unicode-aware class to retrieve associated icons via Windows system image lists
' on XP and above, the image list handle returned by SHGetFileInfo is not the
ExtraLarge or Jumbo sized
' image lists as expected. We'll use SHGetImageList to get the correct handle
If hIML Then
If IconSize >= aisExtraLargeIcon48 Then ' XP or greater O/S
If IIDFromString(StrPtr(IID_IImageList), GUID(0)) = 0 Then
On Error Resume Next
lRtn = SHGetImageList(IconSize, GUID(0), ByVal VarPtr(pIML))
If lRtn = 0& Then
If Err Then ' depending on service pack shell32 did not
export SHGetImageList correctly
Err.Clear ' so we try again using the ordinal exported
lRtn = SHGetImageListXP(IconSize, GUID(0), ByVal
VarPtr(pIML))
If Err Then lRtn = hIML ' assign any non-zero value; will
be using the hIML value
End If
End If
On Error GoTo 0
If lRtn = 0& Then hIML = ObjPtr(pIML)
End If
End If
GetAssociatedIconEx = ImageList_GetIcon(hIML, SHFI.iIcon, ILD_TRANSPARENT)
End If
End Function
m_Version = GetVersion()
Select Case (m_Version And &HFF&)
Case Is > 5 ' Vista or better
m_Version = 2&
Case 5 ' XP or maybe not
If ((m_Version And &HFF00&) \ &H100 > 0&) Then m_Version = 1& Else
m_Version = 0&
Case Else ' less than XP
m_Version = 0&
End Select
If IsWindowUnicode(GetDesktopWindow) <> 0& Then m_Version = m_Version Or 4&
End Sub