Gets a list of installed software

Tips, tricks and other stuff
Post Reply
User avatar

Topic author
Superl
Site Admin
Site Admin
Man of action
Man of action
Posts: 1331
Joined: Sat Apr 16, 2011 7:49 am
12
Location: Montreal, Canada
Contact:

Gets a list of installed software

#2284

Post by Superl »

Gets a list of installed software Introduction:
Gets a list of installed software and, if known, the software's install path.

Code: Select all

/// <summary>
/// Gets a list of installed software and, if known, the software's install path.
/// </summary>
/// <returns></returns>
private string Getinstalledsoftware()
{
//Declare the string to hold the list:
string Software = null;

//The registry key:
string SoftwareKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(SoftwareKey))
{
//Let's go through the registry keys and get the info we need:
foreach (string skName in rk.GetSubKeyNames())
{
using (RegistryKey sk = rk.OpenSubKey(skName))
{
try
{
//If the key has value, continue, if not, skip it:
if (!(sk.GetValue("DisplayName") == null))
{
//Is the install location known?
if (sk.GetValue("InstallLocation") == null) //Nope, not here.
Software += sk.GetValue("DisplayName") + " - Install path not known\n";
else //Yes, here it is...
Software += sk.GetValue("DisplayName") + " - " + sk.GetValue("InstallLocation") + "\n";
}
}
catch (Exception ex)
{
//No, that exception is not getting away... :P
}
}
}
}

return Software;
}
Example usage:

Code: Select all

//Example usage:
private void get_software_list_button__Click(object sender, EventArgs e)
{
      MessageBox.Show(Getinstalledsoftware());
}


Come and say hello in here
Any donation will help click here please.

Have a nice day :103:
Post Reply

Return to “How To Forum”