Hi,
The WMI solution is way to slow for me. I need to poll constantly with
an interval of 5 seconds. It takes about 3 minutes before the WMI
query finishes. Fortunately the registry is a far cleaner and faster
solution.
Below is the C# code which made it possible.
protected bool IsPluginInstalled()
{
bool installed = false;
const string SUB_KEY = @"SOFTWARE\Microsoft\Windows\CurrentVersion
\Uninstall";
using (RegistryKey rootKey = Registry.LocalMachine.OpenSubKey
(SUB_KEY))
{
if (rootKey != null)
{
foreach (string key in rootKey.GetSubKeyNames())
{
try
{
using (RegistryKey productKey = rootKey.OpenSubKey
(key))
{
if (productKey != null)
{
string productName = Convert.ToString
(productKey.GetValue("DisplayName"));
if (productName.Equals("google earth plug-
in", StringComparison.InvariantCultureIgnoreCase))
{
installed = true;
break;
}
}
}
}
catch (Exception e)
{
Debug.WriteLine(e);
}
}
}
}
return installed;
}