public static string DetectPath() { string path = @"C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe"; string clsid = "{2F410E77-24FD-4788-8412-3810115E7BCB}"; if (RegistryKey64.Is64BitOperatingSystem()) { clsid = "{41E0355D-F488-487D-B7BA-D235D5834F1D}"; } RegistryKey64 key = RegistryKey64.OpenKey(RegistryHive.ClassesRoot, @"CLSID\" + clsid + @"\InprocServer32", false, RegistryKey64.RegWow64Options.None); if (key != null) { try { path = key.GetValue("") as string; if (path != null) { path = path.Substring(0, path.LastIndexOf('\\') + 1) + "sgdm.exe"; } } finally { key.Close(); } } return(path); }
protected static RegistryKey64 Open64Or32Key(RegistryHive hKey, string subkey) { RegistryKey64 key; key = RegistryKey64.OpenKey(hKey, subkey, false, RegistryKey64.RegWow64Options.KEY_WOW64_64KEY); if (key != null) { return(key); } key = RegistryKey64.OpenKey(hKey, subkey, false, RegistryKey64.RegWow64Options.KEY_WOW64_32KEY); return(key); }
public static string DetectPath() { string path = ""; RegistryKey64 key = Open64Or32Key(RegistryHive.CurrentUser, @"SOFTWARE\Thingamahoochie\WinMerge"); if (key != null) { try { path = key.GetValue("Executable") as string; } finally { key.Close(); } } if (path == null) { key = RegistryKey64.OpenKey(RegistryHive.ClassesRoot, @"CLSID\{4E716236-AA30-4C65-B225-D68BBA81E9C2}\InprocServer32", false, RegistryKey64.RegWow64Options.KEY_WOW64_32KEY); if (key != null) { try { path = key.GetValue("") as string; if (path != null) { path = path.Substring(0, path.LastIndexOf('\\') + 1) + "WinMergeU.exe"; } } finally { key.Close(); } } } return(path); }