edmundg
asked on
How to return a list of software installed on a computer?
I am just wondering is there anyway to return a list of software which installed on a computer. I am currently using WMI (Windows Management Information) classes to retrieve such information as drive, processor and operating system information. Your help would be gratefully appreciated.
Well you can loop through c:\program files and see the current applications
It is impossible to list ALL software on a system.
You could certainly determine what programs are listed in the Add/Remove section of the conrol panel but that is not always accurate as sometimes applications get orphaned there even though they were uninstalled long ago.
Additionally, not all programs on a system are listed there. Any app that doesn't require installation will simply reside on the hard drive somewhere, and not necessarily in the "Program Files" folder either.
With that info in mind...you can duplicate the Add/Remove list by going to this key in the registry:
HKEY_LOCAL_MACHINE\Softwar e\Microsof t\Windows\ CurrentVer sion\Unins tall
Then simply enumerate all the entries and fetch the DisplayName value from each one.
Regards,
Idle_Mind
You could certainly determine what programs are listed in the Add/Remove section of the conrol panel but that is not always accurate as sometimes applications get orphaned there even though they were uninstalled long ago.
Additionally, not all programs on a system are listed there. Any app that doesn't require installation will simply reside on the hard drive somewhere, and not necessarily in the "Program Files" folder either.
With that info in mind...you can duplicate the Add/Remove list by going to this key in the registry:
HKEY_LOCAL_MACHINE\Softwar
Then simply enumerate all the entries and fetch the DisplayName value from each one.
Regards,
Idle_Mind
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is an example of enumerating the Uninstall key and placing the list into a ListBox:
Imports Microsoft.Win32
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.ICon tainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents ListBox1 As System.Windows.Forms.ListB ox
<System.Diagnostics.Debugg erStepThro ugh()> Private Sub InitializeComponent()
Me.ListBox1 = New System.Windows.Forms.ListB ox
Me.SuspendLayout()
'
'ListBox1
'
Me.ListBox1.Anchor = CType((((System.Windows.Fo rms.Anchor Styles.Top Or System.Windows.Forms.Ancho rStyles.Bo ttom) _
Or System.Windows.Forms.Ancho rStyles.Le ft) _
Or System.Windows.Forms.Ancho rStyles.Ri ght), System.Windows.Forms.Ancho rStyles)
Me.ListBox1.Location = New System.Drawing.Point(8, 8)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(432, 277)
Me.ListBox1.TabIndex = 0
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(448, 294)
Me.Controls.Add(Me.ListBox 1)
Me.Name = "Form1"
Me.Text = "Add/Remove Program Listing"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim rk As RegistryKey = Registry.LocalMachine.Open SubKey("So ftware\Mic rosoft\Win dows\Curre ntVersion\ Uninstall" )
Dim sk As String
Dim appKey As RegistryKey
Dim displayNameValue As Object
Dim displayName As String
ListBox1.Sorted = True
If Not (rk Is Nothing) Then
For Each sk In rk.GetSubKeyNames
appKey = rk.OpenSubKey(sk)
displayNameValue = appKey.GetValue("DisplayNa me")
If Not (displayNameValue Is Nothing) Then
ListBox1.Items.Add(CType(d isplayName Value, String))
End If
Next
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error Accessing Registry")
End Try
End Sub
End Class
Imports Microsoft.Win32
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.ICon
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents ListBox1 As System.Windows.Forms.ListB
<System.Diagnostics.Debugg
Me.ListBox1 = New System.Windows.Forms.ListB
Me.SuspendLayout()
'
'ListBox1
'
Me.ListBox1.Anchor = CType((((System.Windows.Fo
Or System.Windows.Forms.Ancho
Or System.Windows.Forms.Ancho
Me.ListBox1.Location = New System.Drawing.Point(8, 8)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(432, 277)
Me.ListBox1.TabIndex = 0
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(448, 294)
Me.Controls.Add(Me.ListBox
Me.Name = "Form1"
Me.Text = "Add/Remove Program Listing"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim rk As RegistryKey = Registry.LocalMachine.Open
Dim sk As String
Dim appKey As RegistryKey
Dim displayNameValue As Object
Dim displayName As String
ListBox1.Sorted = True
If Not (rk Is Nothing) Then
For Each sk In rk.GetSubKeyNames
appKey = rk.OpenSubKey(sk)
displayNameValue = appKey.GetValue("DisplayNa
If Not (displayNameValue Is Nothing) Then
ListBox1.Items.Add(CType(d
End If
Next
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error Accessing Registry")
End Try
End Sub
End Class