Esempio n. 1
0
        public override void RegApp(string name, string location, string desc)
        {
            var info = new AssemInfo(name, location, desc);

            try
            {
                var rootkey =
                    Registry
                    .CurrentUser
                    .OpenSubKey($@"SOFTWARE\Gstarsoft\GstarCAD\{ProductRootKey}\zh-CN", true);
                RegistryKey appskey = rootkey.CreateSubKey("Applications");

                //注册预加载程序集
                RegistryKey rk = appskey.OpenSubKey(info.Name, true);
                if (rk == null)
                {
                    rk = appskey.CreateSubKey(info.Name);
                    rk.SetValue("DESCRIPTION", info.Description, RegistryValueKind.String);
                    rk.SetValue("LOADER", info.Location, RegistryValueKind.String);
                    rk.SetValue("LOADCTRLS", info.LoadType, RegistryValueKind.DWord);
                    rk.SetValue("MANAGED", 1, RegistryValueKind.DWord);
                }
                else if (rk.GetValue("LOADER").ToString() != info.Location)
                {
                    rk.SetValue("LOADER", info.Location, RegistryValueKind.String);
                }

                rk.Close();
                appskey.Close();
                rootkey.Close();
            }
            catch { }
        }
Esempio n. 2
0
        public override void RegApp(string name, string location, string desc)
        {
            var info = new AssemInfo(name, location, desc);

            try
            {
                var rootkey =
                    Registry
                    .CurrentUser
                    .OpenSubKey(ProductRootKey, true);

                //注册预加载程序集
                using (RegistryKey appskey = rootkey.CreateSubKey("Applications"))
                    using (RegistryKey rk = appskey.CreateSubKey(info.Name))
                    {
                        rk.SetValue("DESCRIPTION", info.Description, RegistryValueKind.String);
                        rk.SetValue("LOADER", info.Location, RegistryValueKind.String);
                        rk.SetValue("LOADCTRLS", info.LoadType, RegistryValueKind.DWord);
                        rk.SetValue("MANAGED", 1, RegistryValueKind.DWord);
                    }

                try
                {
                    //添加信任目录
                    var profileskey = rootkey.OpenSubKey("Profiles");
                    foreach (string keyname in profileskey.GetSubKeyNames())
                    {
                        var    profilekey   = profileskey.OpenSubKey(keyname);
                        var    variableskey = profilekey?.OpenSubKey("Variables", true);
                        string paths        = variableskey?.GetValue("TRUSTEDPATHS")?.ToString();
                        if (paths != null)
                        {
                            List <string> names = new List <string>();
                            if (paths != "")
                            {
                                foreach (string s in paths.Split(';'))
                                {
                                    names.Add(s.ToLower());
                                }
                            }
                            string path = Path.GetDirectoryName(info.Location);
                            if (!names.Contains(path.ToLower()))
                            {
                                names.Add(path);
                                variableskey.SetValue("TRUSTEDPATHS", string.Join(";", names));
                            }
                        }
                        variableskey.Close();
                        profilekey.Close();
                    }
                    profileskey.Close();
                }
                catch { }
                rootkey.Close();
            }
            catch { }
        }
Esempio n. 3
0
        public override void RegApp(string name, string location, string desc)
        {
            var info = new AssemInfo(name, location, desc);

            try
            {
                //注册预加载程序集
                using (var rootkey = Registry.CurrentUser.OpenSubKey(ProductRootKey, true))
                    using (var appskey = rootkey.CreateSubKey("Applications"))
                        using (var rk = appskey.CreateSubKey(info.Name))
                        {
                            rk.SetValue("DESCRIPTION", info.Description, RegistryValueKind.String);
                            rk.SetValue("LOADER", info.Location, RegistryValueKind.String);
                            rk.SetValue("LOADCTRLS", info.LoadType, RegistryValueKind.DWord);
                            rk.SetValue("MANAGED", 1, RegistryValueKind.DWord);
                        }
            }
            catch { }
        }