Contact Us

Contact Us

How To Check If Program Is Installed?

C# Code Snippet – How To Check If Program Is Installed?

 

This function will search the given program display name in the registry and returns true if it is installed.

See the name of the program in Add/Remove Programs list.

public static bool IsProgramInstalled(string displayName, bool x86Platform)

{

string uninstallKey = string.Empty;

 

if (x86Platform)

{

uninstallKey = @”SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”;

}

 

else

{

uninstallKey = @”SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall”;

}

 

using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))

{

 

foreach (string skName in rk.GetSubKeyNames())

{

using (RegistryKey sk = rk.OpenSubKey(skName))

{

if (sk.GetValue(“DisplayName”) != null && sk.GetValue(“DisplayName”).ToString().ToUpper().Equals(displayName.ToUpper()))

{

return true; //exists

}

 

}

}

}

 

return false;

}                 public static bool Contains(string inputString, string strToSearch)

{

return Regex.IsMatch(inputString, strToSearch);

}

Healthcare software development, HL7 Interface, EMR/EHR integration, mHealth, HIPAA compliant