From ba4888d63d5acd704d39d54e9f28fca4bb6d6e8a Mon Sep 17 00:00:00 2001 From: Flamefire Date: Tue, 18 Mar 2014 17:44:33 +0100 Subject: [PATCH] Fix error on 32 bit systems --- Vocaluxe/CProgrammHelper.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Vocaluxe/CProgrammHelper.cs b/Vocaluxe/CProgrammHelper.cs index e1994ced..88c35368 100644 --- a/Vocaluxe/CProgrammHelper.cs +++ b/Vocaluxe/CProgrammHelper.cs @@ -50,6 +50,16 @@ namespace Vocaluxe return false; } + private static bool _KeyExists(string key) + { + using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(key)) + { + if (rk != null) + return true; + } + return false; + } + /// /// Checks if a given program is installed by checking the Uninstall registry key. /// @@ -57,10 +67,11 @@ namespace Vocaluxe /// private static bool _IsProgramInstalled(string name) { - const string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"; - const string uninstallKeyx64 = @"SOFTWARE\WoW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"; + const string baseKey = @"SOFTWARE\"; + const string baseKey64 = @"SOFTWARE\WoW6432Node\"; + const string uninstallKey = @"Microsoft\Windows\CurrentVersion\Uninstall"; name = name.ToLower(); - return _CheckUninstallKey(name, uninstallKey) || _CheckUninstallKey(name, uninstallKeyx64); + return _CheckUninstallKey(name, baseKey + uninstallKey) || (_KeyExists(baseKey64) && _CheckUninstallKey(name, baseKey64 + uninstallKey)); } private static bool _SystemDllExists(string dllName)