Пример #1
0
        public Task <ApplicationDetectionResult> DetectAsync()
        {
            using (var key = Registry.CurrentUser.OpenSubKey(RegistryKeyName, false))
            {
                if (key == null)
                {
                    return(Task.FromResult(ApplicationDetectionResult.NotFound()));
                }

                var installLocation = (string)key.GetValue("Install Path");
                if (string.IsNullOrWhiteSpace(installLocation))
                {
                    return(Task.FromResult(ApplicationDetectionResult.NotFound()));
                }

                var result = ApplicationDetectionResult.Create(this, DefaultDisplayName, installLocation);

                var exe = new FileInfo(Path.Combine(installLocation, "emule.exe"));
                if (exe.Exists)
                {
                    var version = FileVersionInfo.GetVersionInfo(exe.FullName);
                    result.Description = version.ProductName;
                    result.Version     = version.FileVersion;
                }
                else
                {
                    result.IsPresent = false;
                }

                return(Task.FromResult(result));
            }
        }
Пример #2
0
        public async Task<ApplicationDetectionResult> DetectAsync()
        {
            using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
            {
                using (var key = baseKey.OpenSubKey(@"SOFTWARE\qBittorrent"))
                {
                    if (key == null) return ApplicationDetectionResult.NotFound();

                    var installLocation = (string)key.GetValue("InstallLocation");
                    if (string.IsNullOrWhiteSpace(installLocation)) return ApplicationDetectionResult.NotFound();

                    var result = new ApplicationDetectionResult
                    {
                        IsPresent = true,
                        Description = "qBittorrent",
                        InstallLocation = new DirectoryInfo(installLocation),
                        Application = this
                    };

                    if (!result.InstallLocation.Exists) return ApplicationDetectionResult.NotFound();

                    var applicationPath = Path.Combine(result.InstallLocation.FullName, "qbittorrent.exe");
                    if (!File.Exists(applicationPath)) return ApplicationDetectionResult.NotFound();

                    var version = FileVersionInfo.GetVersionInfo(Path.Combine(result.InstallLocation.FullName, "qbittorrent.exe"));
                    result.Version = version.ProductVersion;

                    return result;
                }
            }
        }
Пример #3
0
        public async Task <ApplicationDetectionResult> DetectAsync()
        {
            using (var key = Registry.CurrentUser.OpenSubKey(RegistryKeyName, false))
            {
                if (key == null)
                {
                    return(ApplicationDetectionResult.NotFound());
                }

                var installLocation = (string)key.GetValue("InstallLocation");
                if (installLocation == null)
                {
                    return(ApplicationDetectionResult.NotFound());
                }

                var displayName = (string)key.GetValue("DisplayName") ?? DefaultDisplayName;
                var version     = (string)key.GetValue("DisplayVersion") ?? "Unknown";

                var result = new ApplicationDetectionResult
                {
                    IsPresent       = true,
                    Description     = displayName,
                    InstallLocation = new DirectoryInfo(installLocation),
                    Version         = version,
                    Application     = this
                };

                if (!result.InstallLocation.Exists)
                {
                    result.IsPresent = false;
                }

                return(result);
            }
        }
Пример #4
0
        public async Task<ApplicationDetectionResult> DetectAsync()
        {
            // Look in HKCU first (current user install), then fall back to HKLM (all users install).
            var key = Registry.CurrentUser.OpenSubKey(RegistryKeyName, false);
            if (key == null)
            {
                key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(RegistryKeyName, false);
            }

            if( key == null ) return ApplicationDetectionResult.NotFound();

            using (key)
            {
                var installLocation = (string)key.GetValue("InstallLocation");
                if (installLocation == null) return ApplicationDetectionResult.NotFound();

                var displayName = (string)key.GetValue("DisplayName") ?? DefaultDisplayName;
                var version = (string)key.GetValue("DisplayVersion") ?? "Unknown";

                var result = new ApplicationDetectionResult
                {
                    IsPresent = true,
                    Description = displayName,
                    InstallLocation = new DirectoryInfo(installLocation),
                    Version = version,
                    Application = this
                };

                if (!result.InstallLocation.Exists) result.IsPresent = false;

                return result;
            }
        }
Пример #5
0
        public Task <ApplicationDetectionResult> DetectAsync()
        {
            using (var key = Registry.ClassesRoot.OpenSubKey(@"SOFTWARE\Deluge", false))
            {
                if (key == null)
                {
                    Trace.TraceInformation("Couldn't find Deluge key at HKCR\\SOFTWARE\\Deluge");
                    return(Task.FromResult(ApplicationDetectionResult.NotFound()));
                }

                var startMenuFolder = (string)key.GetValue("Start Menu Folder");
                if (string.IsNullOrWhiteSpace(startMenuFolder))
                {
                    Trace.TraceInformation("Couldn't find Deluge start menu location");
                    return(Task.FromResult(ApplicationDetectionResult.NotFound()));
                }

                // Get the link
                var linkPath = Path.Combine(Environment.ExpandEnvironmentVariables(@"%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs"), startMenuFolder);
                if (!Directory.Exists(linkPath))
                {
                    Trace.TraceInformation("Couldn't find Deluge shortcut folder: " + linkPath);
                    return(Task.FromResult(ApplicationDetectionResult.NotFound()));
                }

                var shortcut = Path.Combine(linkPath, "Deluge.lnk");
                if (!File.Exists(shortcut))
                {
                    Trace.TraceInformation("Couldn't find Deluge shortcut: " + shortcut);
                    return(Task.FromResult(ApplicationDetectionResult.NotFound()));
                }

                var path = ShellLinkHelper.ResolveShortcut(shortcut);
                Trace.TraceInformation("Deluge location is " + path);

                var result = ApplicationDetectionResult.Create(this, "Deluge", Path.GetDirectoryName(path));

                var exe = new FileInfo(path);
                if (!exe.Exists)
                {
                    Trace.TraceInformation("Deluge exe not found @ " + path);
                    result.IsPresent = false;
                }

                var version = FileVersionInfo.GetVersionInfo(exe.FullName);
                result.Description = version.ProductName;
                result.Version     = version.FileVersion;

                return(Task.FromResult(result));
            }

            // DisplayName: Deluge 1.3.15
            // UninstallString: C:\Program Files (x86)\Deluge\deluge-uninst.exe
            var uninstallKey  = @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Deluge";
            var uinstallValue = @"";

            // Recent Apps GUID: {86B4A402-4897-48E8-8D82-0D19C33E1431}
            // AppId: {7C5A40EF-A0FB-4BFC-874A-C0F2E0B9FA8E}\Deluge\deluge.exe
            // AppPath: C:\Program Files (x86)\Deluge\deluge.exe
        }
Пример #6
0
        public async Task<ApplicationDetectionResult> DetectAsync()
        {
            using (var key = Registry.CurrentUser.OpenSubKey(RegistryKeyName, false))
            {
                if (key == null) return ApplicationDetectionResult.NotFound();

                var installLocation = (string)key.GetValue("InstallLocation");
                if (installLocation == null) return ApplicationDetectionResult.NotFound();

                var displayName = (string)key.GetValue("DisplayName") ?? DefaultDisplayName;
                var version = (string)key.GetValue("DisplayVersion") ?? "Unknown";

                var result = new ApplicationDetectionResult
                {
                    IsPresent = true,
                    Description = displayName,
                    InstallLocation = new DirectoryInfo(installLocation),
                    Version = version,
                    Application = this
                };

                if (!result.InstallLocation.Exists) result.IsPresent = false;

                return result;
            }
        }
Пример #7
0
        public Task <ApplicationDetectionResult> DetectAsync()
        {
            // Look in HKCU first (current user install), then fall back to HKLM (all users install).
            var key = Registry.CurrentUser.OpenSubKey(RegistryKeyName, false);

            if (key == null)
            {
                key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(RegistryKeyName, false);
            }

            if (key == null)
            {
                return(Task.FromResult(ApplicationDetectionResult.NotFound()));
            }

            using (key)
            {
                var installLocation = (string)key.GetValue("InstallLocation");
                if (installLocation == null)
                {
                    return(Task.FromResult(ApplicationDetectionResult.NotFound()));
                }

                var displayName = (string)key.GetValue("DisplayName") ?? DefaultDisplayName;
                var version     = (string)key.GetValue("DisplayVersion") ?? "Unknown";

                var result = new ApplicationDetectionResult
                {
                    IsPresent       = true,
                    Description     = displayName,
                    InstallLocation = new DirectoryInfo(installLocation),
                    Version         = version,
                    Application     = this
                };

                if (!result.InstallLocation.Exists)
                {
                    result.IsPresent = false;
                }

                return(Task.FromResult(result));
            }
        }
Пример #8
0
        public async Task <ApplicationDetectionResult> DetectAsync()
        {
            using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
            {
                using (var key = baseKey.OpenSubKey(@"SOFTWARE\qBittorrent"))
                {
                    if (key == null)
                    {
                        return(ApplicationDetectionResult.NotFound());
                    }

                    var installLocation = (string)key.GetValue("InstallLocation");
                    if (string.IsNullOrWhiteSpace(installLocation))
                    {
                        return(ApplicationDetectionResult.NotFound());
                    }

                    var result = new ApplicationDetectionResult
                    {
                        IsPresent       = true,
                        Description     = "qBittorrent",
                        InstallLocation = new DirectoryInfo(installLocation),
                        Application     = this
                    };

                    if (!result.InstallLocation.Exists)
                    {
                        return(ApplicationDetectionResult.NotFound());
                    }

                    var applicationPath = Path.Combine(result.InstallLocation.FullName, "qbittorrent.exe");
                    if (!File.Exists(applicationPath))
                    {
                        return(ApplicationDetectionResult.NotFound());
                    }

                    var version = FileVersionInfo.GetVersionInfo(Path.Combine(result.InstallLocation.FullName, "qbittorrent.exe"));
                    result.Version = version.ProductVersion;

                    return(result);
                }
            }
        }
Пример #9
0
        public Task <ApplicationDetectionResult> DetectAsync()
        {
            using var key = Registry.CurrentUser.OpenSubKey(RegistryKeyName, false);
            if (key == null)
            {
                return(Task.FromResult(ApplicationDetectionResult.NotFound()));
            }

            var installLocation = (string)key.GetValue("Install Path");

            if (string.IsNullOrWhiteSpace(installLocation))
            {
                return(Task.FromResult(ApplicationDetectionResult.NotFound()));
            }

            var result = ApplicationDetectionResult.Create(this, DefaultDisplayName, installLocation);

            var exe = new FileInfo(Path.Combine(installLocation, "emule.exe"));

            if (!exe.Exists)
            {
                result.IsPresent = false;
            }
            else
            {
                var version = FileVersionInfo.GetVersionInfo(exe.FullName);
                result.Description = version.ProductName;
                result.Version     = version.FileVersion;
            }

            // eMule can be configured to store config in the application folder or program data, instead of app data
            var useSharedConfigValue = key.GetValue("UsePublicUserDirectories") ?? 0;

            configFolder = (int)useSharedConfigValue switch
            {
                1 => Environment.SpecialFolder.CommonApplicationData,
                2 => Environment.SpecialFolder.ProgramFilesX86,
                _ => Environment.SpecialFolder.LocalApplicationData
            };

            return(Task.FromResult(result));
        }
Пример #10
0
        public Task <ApplicationDetectionResult> DetectAsync()
        {
            // Look in HKCU first (current user install), then fall back to HKLM (all users install).
            var key = Registry.CurrentUser.OpenSubKey(RegistryKeyName, false);

            if (key == null)
            {
                using var hklm32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
                key = hklm32.OpenSubKey(RegistryKeyName, false);
            }

            if (key == null)
            {
                return(Task.FromResult(ApplicationDetectionResult.NotFound()));
            }

            using (key)
            {
                var installLocation = (string)key.GetValue("InstallLocation");
                if (string.IsNullOrWhiteSpace(installLocation))
                {
                    return(Task.FromResult(ApplicationDetectionResult.NotFound()));
                }

                var displayName = (string)key.GetValue("DisplayName") ?? DefaultDisplayName;
                var version     = (string)key.GetValue("DisplayVersion") ?? "Unknown";

                var result = ApplicationDetectionResult.Create(this, displayName, installLocation);

                if (result.InstallLocation == null || !result.InstallLocation.Exists)
                {
                    return(Task.FromResult(ApplicationDetectionResult.NotFound()));
                }
                ;

                result.Version = version;

                return(Task.FromResult(result));
            }
        }
Пример #11
0
        public Task <ApplicationDetectionResult> DetectAsync()
        {
            using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
            {
                using (var key = baseKey.OpenSubKey(@"SOFTWARE\qBittorrent"))
                {
                    if (key == null)
                    {
                        return(Task.FromResult(ApplicationDetectionResult.NotFound()));
                    }

                    var installLocation = (string)key.GetValue("InstallLocation");
                    if (string.IsNullOrWhiteSpace(installLocation))
                    {
                        return(Task.FromResult(ApplicationDetectionResult.NotFound()));
                    }

                    var result = ApplicationDetectionResult.Create(this, "qBittorrent", installLocation);

                    if (result.InstallLocation == null || !result.InstallLocation.Exists)
                    {
                        return(Task.FromResult(ApplicationDetectionResult.NotFound()));
                    }

                    var applicationPath = Path.Combine(result.InstallLocation.FullName, "qbittorrent.exe");
                    if (!File.Exists(applicationPath))
                    {
                        return(Task.FromResult(ApplicationDetectionResult.NotFound()));
                    }

                    var version = FileVersionInfo.GetVersionInfo(Path.Combine(result.InstallLocation.FullName, "qbittorrent.exe"));
                    result.Version = version.ProductVersion;

                    return(Task.FromResult(result));
                }
            }
        }