Determine installed version of software

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

I want to write a generic method to read the installed version of
software based on the exact software name that is displayed in Add /
Remove programs. Is there a way to do this using C#? I found a
method which will return all the installed software using this
registry key "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
and using System.Management. I'm assuming I can use the same to get
what I need?

Thank you in advance for any help.

TK.
 
Tim said:
I want to write a generic method to read the installed version of
software based on the exact software name that is displayed in Add /
Remove programs. Is there a way to do this using C#? I found a
method which will return all the installed software using this
registry key "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
and using System.Management. I'm assuming I can use the same to get
what I need?

Thank you in advance for any help.

TK.

Some examples of what you are seeing and what you want to do would
probably go a long way of helping us help you here.
 
I found a potential solution after a few hours of Google searching.
The code goes through the entire installed apps section in the
registery uninstall section. The apps I'm looking for are displayed
by their product code in InstallShield. I can pass in a string of the
exact app name and it will work even for those that are displayed by
product name using the displayName variable below. Hope this helps
anyone else looking for this type of a solution.

Again, it needs to be tweaked slightly to pass in the app I'm looking
for return the string of the version that I looked for. But it
appears to work. Hopefully I'll meet my deadline:

//Get all installed apps and version numbers
public void GetInstalledApps()
{
string uninstallKey = (@"SOFTWARE\Microsoft\Windows
\CurrentVersion\Uninstall");
string junk = "";
string Version = @"SOFTWARE\Microsoft\Windows
\CurrentVersion\Uninstall";
using (RegistryKey rk =
Registry.LocalMachine.OpenSubKey(uninstallKey))
using (RegistryKey rv =
Registry.LocalMachine.OpenSubKey(Version))
{
string[] skNames = rk.GetSubKeyNames();
int skNamesLen = skNames.Length;
string skName = null;

string[] svNames = rv.GetSubKeyNames();
int svNamesLen = svNames.Length;
string svName = null;

for (int namesIdx = 0; namesIdx < skNamesLen; namesIdx+
+)//
// foreach (string skName in rk.GetSubKeyNames())
{
skName = skNames[namesIdx];
svName = svNames[namesIdx];

using (RegistryKey sk = rk.OpenSubKey(skName))
{
sk.Name.Replace(uninstallKey, ""); //Root
object displayVersion = null, displayName =
null;

using (RegistryKey sv = rv.OpenSubKey(svName))
{
displayVersion =
sv.GetValue("DisplayVersion");
displayName = sv.GetValue("DisplayName");
if (displayVersion != null && displayName !
= null)
{
//displayValue = (+
+counter).ToString();
//TreeNode node = new
TreeNode(displayValue.ToString());
junk = displayVersion.ToString();
junk = displayName.ToString();
//nd1.Nodes.Add(node);
}
}
}
}
}
}

TK.
 
Back
Top