I have created an uninstall list that is populated when a form loads. I want to add the ability to right click on the item and have an uninstall option. Below is the code that I'm using to show my Uninstall Manager so far.
Private Sub UninstallMgr_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
GetInstalledPrograms()
End Sub
Private Sub GetInstalledPrograms()
With ListView1.Columns
.Add("Software Name", 400) : .Add("Install Location", 300) : .Add("Publisher", 100)
End With
ListView1.View = View.Details ' Display Columns
Dim Software As String = Nothing
Dim SoftwareKey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products"
Using rk As RegistryKey = Registry.LocalMachine.OpenSubKey(SoftwareKey)
For Each skName In rk.GetSubKeyNames
Dim name = Registry.LocalMachine.OpenSubKey(SoftwareKey).OpenSubKey(skName).OpenSubKey("InstallProperties").GetValue("DisplayName")
Dim installocation = Registry.LocalMachine.OpenSubKey(SoftwareKey).OpenSubKey(skName).OpenSubKey("InstallProperties").GetValue("InstallLocation")
'InstallProperties
Dim publisher = Registry.LocalMachine.OpenSubKey(SoftwareKey).OpenSubKey(skName).OpenSubKey("InstallProperties").GetValue("Publisher")
Dim uninstallString = Registry.LocalMachine.OpenSubKey(SoftwareKey).OpenSubKey(skName).OpenSubKey("InstallProperties").GetValue("UninstallString")
'Add the Software information to lstPrograms
If name.ToString <> "" Then
'Declare new ListView Item
Dim list As New ListViewItem
'Set Text Property to Name of Software
list.Text = name.ToString
'Add Install Location
list.SubItems.Add(installocation.ToString)
'Add Publisher
list.SubItems.Add(publisher.ToString)
' Add it to lstPrograms, a listview that will hold our Software List.
ListView1.Items.Add(list)
End If
Next
End Using
End Sub