Hello I've got a list view that opens items inside a folder and displays them. I want to know if there is a way to have the list view display the icons aswell, maybe using shell32 or an imagelist. Here's the code:
Imports System.IO
Imports System.Xml
Imports System.Runtime.InteropServices
Imports Microsoft.VisualBasic
Public Class cv7import
Private Sub cv7import_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim caminho As String
caminho = "C:\Documents and Settings\Software\Ambiente de trabalho\1"
lstvicon.View = View.Details
lstvicon.GridLines = False
lstvicon.FullRowSelect = True
lstvicon.HideSelection = False
lstvicon.MultiSelect = True
lstvicon.Columns.Add("Nome")
lstvicon.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)
Dim DI As System.IO.DirectoryInfo = New System.IO.DirectoryInfo(caminho)
Dim files() As System.IO.FileInfo = DI.GetFiles
Dim file As System.IO.FileInfo
Dim li As ListViewItem
For Each file In files
li = lstvicon.Items.Add(file.Name)
li.Tag = file.FullName
Next
End Sub
End Class
Here's two images, of how it looks and how I want it to look, if it helps.
How I wanted: http://imageshack.us/photo/my-images/21/wantd.png/
How it looks: http://imageshack.us/photo/my-images/13/needk.png/
Best Answer
Well you need to find the extension of the file to start with:
Then you need to find this entry in the
HKEY_CLASSES_ROOT
section of the registry:The default value in this key gives the file type associated with this file in my case
txtfile
(remember that different registries may have different values depending on what the user has set up and what programs are installed)You then need to look up this values
DefaultIcon
key inHKEY_CLASSES_ROOT
:The default value in here gives you the location of the icon and the icon number in my case:
From this point I think you may need to rely on the ExtractIconEX API to extract the icon. This link may also be of use