I had tried to find all the software
installed in my system using c#. There are several ways to find this. Initially
I have tried using DOC command but some the software’s are not listing with
this approach.
The below approach is worked fine for me.
Reading Register data we can easily get all the data of install ed
applications. The below code snippet will help us to identify the installed
softwares.
//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") + " - Unknown Installed path \n"; //Nope, not here.
else
Software += sk.GetValue("DisplayName") + " - " + sk.GetValue("Installed
Location") + "\n"; //Yes, here it is...
}
}
catch
(Exception ex)
{}
}
}
}
Console.Write(Software);
Console.ReadLine();
No comments:
Post a Comment