AdvancedLauncher.Management.ConfigurationManager.GetLauncherPathFromRegistry C# (CSharp) Method

GetLauncherPathFromRegistry() public method

public GetLauncherPathFromRegistry ( IConfiguration config ) : string
config IConfiguration
return string
        public string GetLauncherPathFromRegistry(IConfiguration config)
        {
            try {
                using (RegistryKey reg = Registry.CurrentUser.OpenSubKey(config.LauncherPathRegKey)) {
                    if (reg == null) {
                        return null;
                    }
                    return (string)reg.GetValue(config.LauncherPathRegVal);
                }
            } catch (SecurityException) {
                return null;
            }
        }

Usage Example

Beispiel #1
0
        public Profile CreateProfile()
        {
            var pNew = new Profile()
            {
                Name = "NewProfile",
                Id   = PendingProfiles.Count > 0 ? PendingProfiles.Max(p => p.Id) + 1 : 1
            };

            IConfiguration config = ConfigurationManager.FirstOrDefault();

            if (config != null)
            {
                pNew.GameModel.Type = config.GameType;

                ConfigurationManager CM = ConfigurationManager as ConfigurationManager;
                // we should not provide this api as public
                pNew.GameModel.GamePath     = CM.GetGamePathFromRegistry(config);
                pNew.GameModel.LauncherPath = CM.GetLauncherPathFromRegistry(config);
                if (config.IsWebAvailable)
                {
                    Server serv = config.ServersProvider.ServerList.FirstOrDefault();
                    if (serv != null)
                    {
                        pNew.Rotation.ServerId = serv.Identifier;
                    }
                }
            }
            pNew.News.TwitterUser = Utils.GetDefaultTwitter();
            pNew.LaunchMode       = App.Kernel.Get <LauncherManager>().Default.Mnemonic;

            PendingProfiles.Add(pNew);
            OnCollectionChanged();
            return(pNew);
        }