예제 #1
0
        /// <summary>
        /// 应用进程列表变更。
        /// </summary>
        /// <param name="taskList">
        /// 将应用的进程列表。
        /// </param>
        private void ApplyTaskList(IEnumerable <string> taskList)
        {
            var path = DataContext.GetRegPath(TaskType);

            RegCtrl.RegDelKey(path);
            if ((int)TaskType >> 1 > 0)
            {
                foreach (var task in taskList)
                {
                    RegCtrl.RegSetValue(
                        new RegKey(path.HKey, $"{path.LpSubKey}\\{{{new Guid()}}}", @"ItemData",
                                   RegistryValueKind.String, task));
                }
            }
            else
            {
                var i = 1;
                foreach (var task in taskList)
                {
                    RegCtrl.RegSetValue(
                        new RegKey(path.HKey, path.LpSubKey, i++.ToString(), RegistryValueKind.String, task));
                }
            }
            DataContext.RefrushData();
        }
예제 #2
0
        /// <inheritdoc />
        /// <summary>
        /// 切换注册表状态。
        /// </summary>
        /// <returns>
        /// true表示切换后注册表处于开启状态。
        /// false表示切换后注册表处于关闭状态。
        /// </returns>
        public override bool SwapStatus()
        {
            var regStores = State ? OffRegStores : OnRegStores;

            foreach (var reg in regStores)
            {
                if (!reg.IsNecessary)
                {
                    continue;
                }
                if (reg.IsNull)
                {
                    RegCtrl.RegDelKey(reg.GetRegPath());
                }
                else
                {
                    RegCtrl.RegSetValue(reg.GetRegKey());
                }
            }
            return(base.SwapStatus());
        }