lundi 27 octobre 2014

to get install software list and installed software path from hard disk in c#


Vote count:

0




is that any way to get installed software list and installed software path from hard disk.



  1. using registry

  2. using search in all drive


1.I am using this code to get file path from registry but i am not getting installed file path i am getting only installed file name.



string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key))
{
foreach (string subkey_name in key.GetSubKeyNames())
{
using (RegistryKey subkey = key.OpenSubKey(subkey_name))
{
// Console.WriteLine(subkey.GetValue("DisplayName"));
if (subkey.GetValue("DisplayName") == "ActiveTeach Images Book 3")
{

}
}
}
}


2.I am using this code but problem in duplicate .I need only installed folder path.



DriveInfo[] allDrives = DriveInfo.GetDrives();


foreach (DriveInfo d in allDrives)
{
try
{
//DirectoryInfo di = new DirectoryInfo(d.Name);
// DirectoryInfo di = new DirectoryInfo(d.Name);
var aa = Directory.GetDirectories(d.Name);
foreach (string dirName in aa)
{
if (!dirName.Contains("Documents and Settings".ToUpper()) && !dirName.Contains("$Recycle.Bin".ToUpper()) && !dirName.Contains("PerfLogs".ToUpper()))
{
DirectoryInfo di = new DirectoryInfo(dirName);

DirectoryInfo[] arrdi = di.GetDirectories("*", SearchOption.AllDirectories);

foreach (DirectoryInfo dr in arrdi)
{
//if (dr.Name == strApp3)
//{
// flag = true;
// lblMsg.Content = dr.FullName;
// arrInstalled.Add(dr.FullName);
// break;
//}
if (dr.Name == strApp3)
{
//flag = true;
lblMsg.Content = dr.FullName;
arrInstalled.Add(dr.FullName);
strPath = strPath + "|" + dr.FullName;
// break;
}
}
}
//if (flag == true)
//{
// break;
//}
}
//if (flag == true)
//{
// break;
//}
}
catch (Exception ex1)
{
continue;

}
}


asked 1 min ago







to get install software list and installed software path from hard disk in c#

Aucun commentaire:

Enregistrer un commentaire