One thing; the registry is not always going to contain this information on every program, so you should have an Else statement to check the sub key in the registry:
InstallLocation
if the
DisplayName
is not null, then the program is installed, so look for an install path in the registry sub key
InstallLocation
, and get the file version from the actual file build using System.IO fileinfo properties if you know the file name.
(the only issue you have here is knowing what the file name of the executable is; because that's nearly never available in the Uninstall section of the registry sub keys.) I am sure the path is stored somewhere in the registry... for that you will have to research or maybe someone here will know.
Secondly, you are using a boolean here:
if (displayFF86version.Equals(FF86_version))
because the equals represents a Boolean check to see if its a match to the variable you pass to .Equals() which will always return false if the value does not exist or is not a match. You should also check if
displayFF86version
is not null first prior to the statement above:
if (!(displayFF86version == Null)) {
}
and if it is null, then either cypher through
WMI
for the Executable path for the file name in order to get the file version as suggested above. Something like this might work for WMI searching:
{
Management.ManagementObjectCollection ManobjectReturn = default(Management.ManagementObjectCollection);
Management.ManagementObjectSearcher ManobjectSearch = default(Management.ManagementObjectSearcher);
Management.ManagementObject Manobject = default(Management.ManagementObject);
ManobjectSearch = new Management.ManagementObjectSearcher("Select * from Win32_Product");
ManobjectReturn = ManobjectSearch.Get;
foreach ( Manobject in ManobjectReturn) {
string Address = Convert.ToString(Manobject("InstallLocation"));
string NewExeName = Convert.ToString(Manobject("Name"));
Interaction.MsgBox(string.Format("{0} Location {1} ", Manobject("Name"), Manobject("InstallLocation")));
}
}
One other thing in your Conditional operator logic:
if (parsedversion >= minimumversion)
return true;
}
The Parsed version is going to be the file version, and assuming
minimumversion
is meant to be the latest available version, your logic should be <= less than or equal to; because your parsed version will never be greater than the available version.
Apart from that, your code looks Ok.