Exemplo n.º 1
0
 /// <inheritdoc />
 /// <summary>
 /// 查询当前注册表状态。
 /// </summary>
 /// <returns>
 /// true表示注册表状态处于开启状态,
 /// false表示注册表状态处于关闭状态。
 /// </returns>
 public override bool CheckStatus()
 {
     foreach (var regStore in OnRegStores)
     {
         if (!regStore.IsNecessary)
         {
             continue;
         }
         try
         {
             var reg = RegCtrl.RegGetValue(regStore.GetRegPath());
             if (reg.LpValue != regStore.LpValue)
             {
                 return(State = false);
             }
         }
         catch (Exception e)
         {
             if (!regStore.IsNull || e.GetType() != typeof(NullReferenceException))
             {
                 throw;
             }
         }
     }
     return(State = true);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 初始化进程信息。
        /// </summary>
        /// <param name="taskType">
        /// 进程信息类型。
        /// </param>
        /// <returns>
        /// 进程信息注册表信息。
        /// </returns>
        private static string[] InitTask(TASK_TYPE_FLAGS taskType)
        {
            var path = GetRegPath(taskType);

            string[] regkeys;
            var      list = new ArrayList();

            try
            {
                if ((int)taskType >> 1 > 0)
                {
                    var regs = RegCtrl.RegEnumKey(path);
                    foreach (var reg in regs)
                    {
                        var tmp = RegCtrl.RegGetValue(new RegPath(reg.HKey, reg.LpSubKey, @"ItemData"));
                        var str = tmp.LpValue.ToString();
                        if (tmp.LpKind == RegistryValueKind.ExpandString)
                        {
                            str = RegCtrl.RegGetValue(new RegPath(str, true)).LpValue.ToString();
                        }
                        list.Add(str);
                    }
                }
                else
                {
                    var regs = RegCtrl.RegEnumValue(path);
                    foreach (var reg in regs)
                    {
                        list.Add(reg.LpValue.ToString());
                    }
                }
            }
            catch (Exception e)
            {
                if (e.GetType() != typeof(NullReferenceException))
                {
                    throw new Exception(nameof(InitTask));
                }
            }
            finally
            {
                list.Sort();
                regkeys = list.ToArray() as string[];
            }
            return(regkeys);
        }
Exemplo n.º 3
0
        private void RefrushPwd()
        {
            Password = RegCtrl.RegGetValue(new RegPath(REG_ROOT_KEY.HKEY_CLASSES_ROOT, @"CLSID\{1BB077CA-FEC5-479F-AA85-11CDFBFA4042}", AESCrypt.Encrypt(@"Password")));
            string pwd = Password.LpValue as string;

            if (pwd is null)
            {
                LblCurrentPwd.Text = string.Empty;
            }
            else
            {
                try
                {
                    LblCurrentPwd.Text = AESCrypt.Decrypt(pwd);
                }
                catch
                {
                    LblCurrentPwd.Text = @"密码无效!";
                }
            }
        }
Exemplo n.º 4
0
 private static RegKey InitPwd()
 {
     return(RegCtrl.RegGetValue(new RegPath(REG_ROOT_KEY.HKEY_CLASSES_ROOT, $"CLSID\\{{{MyGuid}}}", AESCrypt.Encrypt(@"Password"))));
 }