How to open the icons dialog box of shell32.dll?

  • Thread starter Thread starter yxq
  • Start date Start date
Hi,

Use the extracticonex api to get the icons. The Geticon function
below will return an arraylist of the large and small icons in the file.
GetIcon("shell32.dll")
Private Declare Function ExtractIconEx Lib "shell32.dll" Alias
"ExtractIconExA" _

(ByVal lpszFile As String, ByVal nIconIndex As Integer, _

ByVal phiconLarge() As IntPtr, ByVal phiconSmall() As IntPtr, _

ByVal nIcons As Integer) As Integer



Private Function GetIcon(ByVal Path As String) As ArrayList

Dim Large() As IntPtr

Dim Small() As IntPtr

Dim i, x As Integer

Dim cIcon As clsIconsFromFile

Dim arIcons As ArrayList

i = ExtractIconEx(Path, -1, Large, Small, -1) ' get number of icons

ReDim Large(i - 1)

ReDim Small(i - 1)

i = ExtractIconEx(Path, 0, Large, Small, i)

arIcons = New ArrayList

For x = 0 To i - 1

cIcon = New clsIconsFromFile

cIcon.Large = Icon.FromHandle(Large(x))

cIcon.Small = Icon.FromHandle(Small(x))

arIcons.Add(cIcon)

Next x

Return arIcons

End Function



Public Class clsIconsFromFile

Private m_icLarge As Icon

Private m_icSmall As Icon

Public Property Large() As Icon

Get

Return m_icLarge

End Get

Set(ByVal Value As Icon)

m_icLarge = Value

End Set

End Property

Public Property Small() As Icon

Get

Return m_icSmall

End Get

Set(ByVal Value As Icon)

m_icSmall = Value

End Set

End Property

End Class



Ken
 
Back
Top