Question Adding icons (:

metalm3

New member
Joined
Jul 21, 2010
Messages
4
Programming Experience
Beginner
Hi there. May I know how do I get the icon of a program to display along with the name of it? TBProgram.jpg

VB.NET:
Public Partial Class MainForm
	Public Sub New()
		' The Me.InitializeComponent call is required for Windows Forms designer support.
		Me.InitializeComponent()

        Try
            Dim rk As RegistryKey = Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Uninstall")
            Dim sk As String
            Dim appKey As RegistryKey
            Dim displayNameValue As Object
            Dim displayName As String
            
            If Not (rk Is Nothing) Then
                For Each sk In rk.GetSubKeyNames
                    appKey = rk.OpenSubKey(sk)
                    displayNameValue = appKey.GetValue("DisplayName")
                    If Not (displayNameValue Is Nothing) Then
                        listView1.Items.Add(CType(displayNameValue, String))
                    End If
                Next
            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Error Accessing Registry")
        End Try

		
		'
		' TODO : Add constructor code after InitializeComponents
		'

	
	End Sub


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListView1.View = View.Details
        ListView1.Width = 400

       
        ListView1.Columns.Add("Name", 100, HorizontalAlignment.Left)
        ListView1.Columns.Add("Icon", 37, HorizontalAlignment.Left)
        ListView1.AllowColumnReorder = True

        ListView1.Columns(0).DisplayIndex = 1
    End Sub
    
 

End Class

Thank you! :)

EDIT: I know this has been asked a billion time. But when I tried to get the codes together, I get many warnings and exception errors. So yeah, I guess here's the place. :) Once again, thank you! :)
 
Last edited:
If you can find the path for executable you can use this: Icon.ExtractAssociatedIcon Method (System.Drawing)
I see some have set a DisplayIcon node with this path, and some have a InstallLocation folder path from where you may be able to find a .exe.
 
@JohnH
Hello there, sir. I wouldn't be able to list all the icons manually typing their directory paths. Sorry if I've misunderstood your point. :)
Thanks! :D
 
No, you do need the .exe path, as explained.
 
Back
Top