Obtain the installed software and path through the registry. Instance code:
Using (RegistryKey key = Registry. LocalMachine. OpenSubKey (@ "SoftwareMicrosoftWindowsCurrentVersionUninstall", false ))
{
If (key! = Null) // determines whether an object exists.
{
Foreach (string keyName in key. GetSubKeyNames () // traverses the string array of the subitem name
{
Using (RegistryKey key2 = key. OpenSubKey (keyName, false) // traverses the subitem Node
{
If (key2! = Null)
{
String softwareName = key2.GetValue ("DisplayName", ""). ToString (); // obtain the software name
String installLocation = key2.GetValue ("InstallLocation", ""). ToString (); // obtain the installation path
If (! String. IsNullOrEmpty (installLocation ))
{
// Add the information to the ListView Control
ListViewItem item = new ListViewItem (softwareName );
Item. SubItems. Add (installLocation );
ListView1.Items. Add (item );
}
}
}
}
}
}
}