Sumit Kumawat

Sumit Kumawat

  • NA
  • 454
  • 415.9k

how to get install location of from registry in c#?

Dec 2 2017 9:28 AM
Hi all 
i want to fetch install location of all products in my app so for that purpose i am using registry class and using below string value for it
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\UnInstall"
and
"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\UnInstall" for 64 bit version.
but it is not giving me details of all products for example
notepad ++ available in above path in registry editor but using my code it is not displaying the values for notepad.
 
below is my code
StreamWriter sw = new StreamWriter(@"D:\localmachineProducts64.txt", true);
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))
{
foreach (string skName in rk.GetSubKeyNames())
{
using (RegistryKey sk = rk.OpenSubKey(skName))
{
try
{
sw.Write(sk.GetValue("DisplayName") + "\t" + sk.GetValue("InstallLocation"));
sw.Write(sw.NewLine);
count++;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
sw.Write("Total count :=" + count);
}
sw.Close();
 

Answers (1)