Esempio n. 1
0
 /// <summary>
 /// 値を取得
 /// </summary>
 private void GetValues()
 {
     using (RegistryKey regKey = RegistryControl.GetRegistryKey(Path, false, false))
     {
         GetValues(regKey);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// セキュリティ情報を取得
 /// </summary>
 private void GetSecurity()
 {
     using (RegistryKey regKey = RegistryControl.GetRegistryKey(Path, false, false))
     {
         GetSecurity(regKey);
     }
 }
Esempio n. 3
0
        private void GetSecurity(RegistryKey regKey)
        {
            RegistrySecurity security = regKey.GetAccessControl();

            this.Owner = security.GetOwner(typeof(NTAccount)).Value;
            //this.Access = RegistryControl.AccessToString(regKey);
            this.Access    = RegistryControl.AccessRuleToString(security.GetAccessRules(true, false, typeof(NTAccount)));
            this.Inherited = !security.AreAccessRulesProtected;
        }
Esempio n. 4
0
        private void GetValues(RegistryKey regKey)
        {
            Values = new SerializableDictionary <string, string>();

            string[] valueNames = regKey.GetValueNames();
            Array.Sort(valueNames, StringComparer.OrdinalIgnoreCase);
            foreach (string name in valueNames)
            {
                RegistryValueKind valueKind = regKey.GetValueKind(name);

                Values[name] = RegistryControl.ValueKindToString(valueKind) + ":" +
                               RegistryControl.RegistryValueToString(regKey, name, valueKind, true);

                /*
                 * switch (valueKind)
                 * {
                 *  case RegistryValueKind.String:
                 *      Values[name] = Item.REG_SZ + ":" + regKey.GetValue(name);
                 *      break;
                 *  case RegistryValueKind.DWord:
                 *      Values[name] = Item.REG_DWORD + ":" + regKey.GetValue(name).ToString();
                 *      break;
                 *  case RegistryValueKind.QWord:
                 *      Values[name] = Item.REG_QWORD + ":" + regKey.GetValue(name).ToString();
                 *      break;
                 *  case RegistryValueKind.ExpandString:
                 *      Values[name] = Item.REG_EXPAND_SZ + ":" +
                 *          regKey.GetValue(name, "", RegistryValueOptions.DoNotExpandEnvironmentNames);
                 *      break;
                 *  case RegistryValueKind.Binary:
                 *      //Values[name] = Item.REG_BINARY + ":" +
                 *      //    RegistryControl.RegBinaryBytesToString(regKey.GetValue(name) as byte[]);
                 *      Values[name] = Item.REG_BINARY + ":" +
                 *          RegistryControl.RegistryValueToString(regKey, name, valueKind, true);
                 *
                 *      break;
                 *  case RegistryValueKind.MultiString:
                 *      Values[name] = Item.REG_MULTI_SZ + ":" +
                 *          string.Join("\\0", regKey.GetValue(name) as string[]);
                 *      break;
                 *  case RegistryValueKind.None:
                 *      Values[name] = Item.REG_NONE + ":";
                 *      break;
                 * }*/
            }
        }
Esempio n. 5
0
        /// <summary>
        /// PowerShell用のレジストリキーパスを取得
        /// </summary>
        /// <returns></returns>
        public string GetPSPath()
        {
            string keyName = Path.Substring(Path.IndexOf("\\") + 1);

            switch (RegistryControl.GetRootkey(Path).ToString())
            {
            case Item.HKEY_CLASSES_ROOT: return(System.IO.Path.Combine(Item.HKCR + ":", keyName));

            case Item.HKEY_CURRENT_USER: return(System.IO.Path.Combine(Item.HKCU + ":", keyName));

            case Item.HKEY_LOCAL_MACHINE: return(System.IO.Path.Combine(Item.HKLM + ":", keyName));

            case Item.HKEY_USERS: return(System.IO.Path.Combine(Item.HKU + ":", keyName));

            case Item.HKEY_CURRENT_CONFIG: return(System.IO.Path.Combine(Item.HKCC + ":", keyName));
            }
            return(string.Empty);
        }