DataTable dt;
private void CreateTable()
{
dt = new DataTable();
dt.Columns.Add("SoftWare Name", typeof(string));
dt.Columns.Add("Install Path", typeof(string));
}
private void GetAllSoftWarePath()
{
using (RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall", false))
{
if (key != null)
{
foreach (string keyName in key.GetSubKeyNames())
{
using (RegistryKey key2 = key.OpenSubKey(keyName, false))
{
if (key2 != null)
{
string softwareName = key2.GetValue("DisplayName", "").ToString();
string installLocation = key2.GetValue("InstallLocation", "").ToString();
if (!string.IsNullOrEmpty(installLocation) && !string.IsNullOrEmpty("DisplayName"))
{
DataRow dr = this.dt.NewRow();
dr["SoftWare Name"] = softwareName;
dr["Install Path"] = installLocation;
this.dt.Rows.Add(dr);
}
}
}
}
}
}
}
