InstalledSotwareList

Vipul
Posted by in C# category on for Beginner level | Views : 4741 red flag

These lines of code can display installed sotwares in your computer.
Introduction

This Article is useful for getting list of installed softwares in your local system.

It will show programs path where it is install.

Following following steps

1.Take one windows application

2.Add one windows form

2.In form1.cs

Write following codes

using Microsoft.Win32;

private void Form1_Load(object sender, EventArgs e)

{

MessageBox.Show(Getinstalledsoftware());

}

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)

Software += sk.GetValue("DisplayName") + " - Install path not known\n"; //Nope, not here.

else

Software += sk.GetValue("DisplayName") + " - " + sk.GetValue("InstallLocation") + "\n"; //Yes, here it is...

}

}

catch (Exception ex)

{

//No, that exception is not getting away... :P

}

}

}

}

return Software;

}

Conclusion
Run the page and see the magic.
Page copy protected against web site content infringement by Copyscape

About the Author

Vipul
Full Name: vipul vk
Member Level: Starter
Member Status: Member
Member Since: 4/15/2009 9:08:15 PM
Country:

http://www.dotnetfunda.com
Working as a software developer

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)