Click here to Skip to main content
15,891,841 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hey am having a little problem
i need help to list installed programs on my in a listview with 4 columns
the columns names are (name,publisher,size,version)
i have tried it with the following codes
VB
Imports Microsoft.win32
Imports system.IO
 
public class form1
Dim UnInstallCmdStr As Object
    Dim CurrentRegKeyObj As Object
    Dim ApplicationObj As String
    Dim TempBachFile As Object

    Private Property RegistryPath As Object

    Private Property processObj As Object

    Private Property IsMyAppBool As Boolean

    Private Property RegistryKeyObj As RegistryKey


   Dim Key, Reader As RegistryKey, Y As String
        Key = Registry.LocalMachine.OpenSubKey _
        ("software\Microsoft\windows\CurrentVersion\Uninstall", False)
        For Each x In Key.GetSubKeyNames
            Reader = Registry.LocalMachine.OpenSubKey _
                ("software\Microsoft\windows\CurrentVersion\Uninstall\" & x, False)
            If Reader.GetValueNames().Contains("DisplayName") Then
               columnheader1 =("DisplayName")
               columnheader2 = ("publisher")
               columnheader3 = ("size")
               columnheader4 = ("version")
                If Not Listview.Items.Contains(Y) Then Listview.Items.Add(Y)

            End If
        Next

am doing this in the visual basic programming language
Posted
Updated 28-Oct-12 18:00pm
v2
Comments
Sergey Alexandrovich Kryukov 28-Oct-12 21:45pm    
OK, and what's the question? And fix your tag. It's "VB.NET", not "VB". And stop hard-coding any immediate constants in your code.
--SA
sean871 28-Oct-12 22:50pm    
ok what am really trying to do is to get all installed programs to be listed on a list view and i got four columns (name,publisher,size and version)
but the code i posted above gave me an error in the line If Not Listview.Items.Contains(Y) Then Listview.Items.Add(Y)
and the error was the first (Y)

you're not ever *defining* Y as anything ...

Additionally, this is not the way to do it ...

Have a look at the Automation Model[^], specifically, the Products property of the Installer [^]object

The installer is created with a CreateObject("WindowsInstaller.Installer") call
 
Share this answer
 
VB
Dim Key, Reader As RegistryKey, Y As String
        Key = Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Uninstall", False)
        For Each x In Key.GetSubKeyNames
            Reader = Registry.LocalMachine.OpenSubKey _
("Software\Microsoft\Windows\CurrentVersion\Uninstall\" & x, False)
            If Reader.GetValueNames().Contains("DisplayName") Then
                Y = Reader.GetValue("DisplayName")
                If Not lbx.Items.Contains(Y) Then lbx.Items.Add(Y)
            End If

Next
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900