Kindly post the code you use to extract the icon and to add it to the
image list.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Public Function ExtractIcons(ByVal iconfile As String, ByVal iconindex As
Int32) As Icon
Try
Dim hIcon As IntPtr
hIcon =
ExtractIcon(System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0)),
iconfile, iconindex)
Return Icon.FromHandle(hIcon)
Catch ex As Exception
End Try
Return Nothing
End Function
Application.EnableVisualStyles()
............................
Imagelist.ColorDepth = ColorDepth.Depth32Bit
Dim ListViewItem As ListViewItem = New ListViewItem("Test")
ListView1.Items.Add(ListViewItem)
Dim tempIcon As Icon = ExtractIcons("c:\test.exe", 0)
If Not tempIcon Is Nothing Then
ImageList1.Images.Add(tempIcon)
ListViewItem.ImageIndex = ImageList1.Images.Count - 1
End If
"Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at>
OD45IKFg...@TK2MSFTNGP05.phx.gbl...
I guess it's not the problem, but according to the documentation of the ExtractIcon function,
the first argument must be NULL (Intptr.Zero).
Also have a look at the Icon.ExtractAssociatedIcon function.
--
Armin