Click here to Skip to main content
Click here to Skip to main content

Get List of Installed Applications of System in C#

, 6 Jun 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
How to list the installed applications of your system and their setup details in C# language

Introduction

In this tip, we will explain how to list the installed applications of your system and their setup details in C# language.

Background

This tip is based on a Registry key whose address is HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall and you can find there many subkeys which help us to have different details of installed applications.

Using the Code

So for doing what we want, we must follow the steps given below:

  1. Add a listviewer and a button to your design form.
  2. We want use "RegistryKey" class, so add "using Microsoft.Win32" to your project usings.
  3. Put this code in your button click event:
    string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
                using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))
                {
                    foreach (string skName in rk.GetSubKeyNames())
                    {
                        using (RegistryKey sk = rk.OpenSubKey(skName))
                        {
                            try
                            {
    
                                var displayName = sk.GetValue("DisplayName");
                                var size = sk.GetValue("EstimatedSize");
    
                                ListViewItem item;
                                if (displayName != null)
                                {
                                    if (size != null)
                                        item = new ListViewItem(new string[] {displayName.ToString(), 
                                                           size.ToString()});
                                    else
                                        item = new ListViewItem(new string[] { displayName.ToString() });
                                    lstDisplayHardware.Items.Add(item);
                                }
                            }
                            catch (Exception ex)
                            { }
                        }
                    }
                    label1.Text += " (" + lstDisplayHardware.Items.Count.ToString() + ")";
                }  

    Explanation: In this code, at first, we defined a registry command in a specific address (uninstallKey). Then, we use DisplayName and EstimatedSize subkeys which show us Name and Size of all installed apps, and at the end, the result will be shown in listviewer.

  4. You can use all subkeys in the below list:
    Value / Windows Installer property
    
    DisplayName ==> ProductName property
    DisplayVersion ==> Derived from ProductVersion property
    Publisher ==> Manufacturer property
    VersionMinor ==> Derived from ProductVersion property
    VersionMajor ==> Derived from ProductVersion property
    Version ==> Derived from ProductVersion property
    HelpLink ==> ARPHELPLINK property
    HelpTelephone ==> ARPHELPTELEPHONE property
    InstallDate ==> The last time this product received service. 
    The value of this property is replaced each time a patch is applied or removed from 
    the product or the /v Command-Line Option is used to repair the product. 
    If the product has received no repairs or patches this property contains 
    the time this product was installed on this computer.
    InstallLocation ==> ARPINSTALLLOCATION property
    InstallSource ==> SourceDir property
    URLInfoAbout ==> ARPURLINFOABOUT property
    URLUpdateInfo ==> ARPURLUPDATEINFO property
    AuthorizedCDFPrefix ==> ARPAUTHORIZEDCDFPREFIX property
    Comments ==> Comments provided to the Add or Remove Programs control panel.
    Contact ==> Contact provided to the Add or Remove Programs control panel.
    EstimatedSize ==> Determined and set by the Windows Installer.
    Language ==> ProductLanguage property
    ModifyPath ==> Determined and set by the Windows Installer.
    Readme ==> Readme provided to the Add or Remove Programs control panel.
    UninstallString ==> Determined and set by Windows Installer.
    SettingsIdentifier ==> MSIARPSETTINGSIDENTIFIER property

Source: http://msdn.microsoft.com/en-us/library/aa372105(v=vs.85).aspx

Note: Also, you can have this method in your code instead of the above code:

try
    {
      string[] row = { sk.GetValue("DisplayName").ToString() , 
      sk.GetValue("EstematedSize").ToString()};
      var listViewItem = new ListViewItem(row);
      lstDisplayHardware.Items.Add(listViewItem);
    }

catch (Exception ex)
    { }

Now you build your program!

License

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

Share

About the Author

Amir Nasrollahi
CEO
United States United States
- Founder & CEO at Artificial Intelligence Developers - (AID)
- CSM Technology Founder
- Research and Development in the field of "Cloud Computing" and various topics of cloud science, artificial intelligence, speech and image processing, any platform projects design and construction.

Comments and Discussions

 
QuestionNeeds a second registry location for 64-bit OSes [modified] Pinmemberjfos15-Jun-14 13:44 
QuestionYou may not have registry permissions PinmemberFatCatProgrammer6-Jun-14 3:34 
GeneralThank you PinprofessionalEmre Ataseven6-Jun-14 3:11 
AnswerRe: Thank you PinprofessionalAmir Mohammad Nasrollahi6-Jun-14 3:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.141022.1 | Last Updated 6 Jun 2014
Article Copyright 2014 by Amir Nasrollahi
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid