当前位置: 首页>>代码示例>>C#>>正文


C# RegistryKey.GetSubKeyNames方法代码示例

本文整理汇总了C#中Microsoft.Win32.RegistryKey.GetSubKeyNames方法的典型用法代码示例。如果您正苦于以下问题:C# RegistryKey.GetSubKeyNames方法的具体用法?C# RegistryKey.GetSubKeyNames怎么用?C# RegistryKey.GetSubKeyNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Win32.RegistryKey的用法示例。


在下文中一共展示了RegistryKey.GetSubKeyNames方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyFromRegistry

 public void CopyFromRegistry(RegistryKey keyToSave)
 {
     if (keyToSave == null)
     {
         throw new ArgumentNullException("keyToSave");
     }
     this.ValueNames = keyToSave.GetValueNames();
     if (this.ValueNames == null)
     {
         this.ValueNames = new string[0];
     }
     this.Values = new object[this.ValueNames.Length];
     for (int i = 0; i < this.ValueNames.Length; i++)
     {
         this.Values[i] = keyToSave.GetValue(this.ValueNames[i]);
     }
     this.KeyNames = keyToSave.GetSubKeyNames();
     if (this.KeyNames == null)
     {
         this.KeyNames = new string[0];
     }
     this.Keys = new SerializableRegistryKey[this.KeyNames.Length];
     for (int j = 0; j < this.KeyNames.Length; j++)
     {
         this.Keys[j] = new SerializableRegistryKey(keyToSave.OpenSubKey(this.KeyNames[j]));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:SerializableRegistryKey.cs

示例2: IsApplicationInKey

 private static bool IsApplicationInKey(RegistryKey key, string applicationName)
 {
     return key.GetSubKeyNames()
         .Select(key.OpenSubKey)
         .Select(subkey => subkey.GetValue("DisplayName") as string)
         .Any(displayName => displayName != null && displayName.Contains(applicationName));
 }
开发者ID:dineshkummarc,项目名称:Espera,代码行数:7,代码来源:RegistryHelper.cs

示例3: GetSubKey

 /// <summary>
 /// 获取注册表项的子节点,并将其添加到树形控件节点中
 /// </summary>
 /// <param name="nodes"></param>
 /// <param name="rootKey"></param>
 public void GetSubKey(TreeNodeCollection nodes, RegistryKey rootKey)
 {
     if (nodes.Count != 0) return;
     //获取项的子项名称列表
     string[] keyNames = rootKey.GetSubKeyNames();
     //遍历子项名称
     foreach (string keyName in keyNames)
     {
     try
     {
     //根据子项名称功能注册表项
     RegistryKey key = rootKey.OpenSubKey(keyName);
     //如果表项不存在,则继续遍历下一表项
     if (key == null) continue;
     //根据子项名称创建对应树形控件节点
     TreeNode TNRoot = new TreeNode(keyName);
     //将注册表项与树形控件节点绑定在一起
     TNRoot.Tag = key;
     //向树形控件中添加节点
     nodes.Add(TNRoot);
     }
     catch
     {
     //如果由于权限问题无法访问子项,则继续搜索下一子项
     continue;
     }
     }
 }
开发者ID:dalinhuang,项目名称:wdeqawes-efrwserd-rgtedrtf,代码行数:33,代码来源:FormExplorer.cs

示例4: GetSubKeys

        static IEnumerable<RegistryKey> GetSubKeys(RegistryKey keyParentArg)
        {
            var keysFound = new List<RegistryKey>();

            try
            {
                if (keyParentArg.SubKeyCount > 0)
                {
                    foreach (var subKeyName in keyParentArg.GetSubKeyNames())
                    {
                        var keyChild = keyParentArg.OpenSubKey(subKeyName);
                        if (keyChild != null)
                        {
                            keysFound.Add(keyChild);
                        }

                        var keyGrandChildren = GetSubKeys(keyChild);

                        if (keyGrandChildren != null)
                        {
                            keysFound.AddRange(keyGrandChildren);
                        }
                    }

                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.GetBaseException());
                throw;
            }
            return keysFound;
        }
开发者ID:CuneytKukrer,项目名称:TestProject,代码行数:33,代码来源:Program.cs

示例5: GetSubKey

        private static void GetSubKey(RegistryKey key)
        {
            foreach (string skName in key.GetSubKeyNames())
            {
                using (RegistryKey sk = key.OpenSubKey(skName))
                {
                    if (sk == null)
                    {
                        continue;
                    }
                    if (sk.SubKeyCount > 0)
                    {
                        GetSubKey(sk);

                    }
                    if (sk.ValueCount > 0)
                    {
                        foreach (var valueName in sk.GetValueNames())
                        {
                            //Console.WriteLine(valueName);
                        }
                    }
                }
            }
        }
开发者ID:CuneytKukrer,项目名称:TestProject,代码行数:25,代码来源:Program.cs

示例6: Slic3r

        public Slic3r()
        {
            InitializeComponent();
            if (Main.IsMono)
                panelCloseButtons.Location = new Point(panelCloseButtons.Location.X, panelCloseButtons.Location.Y - 14);
            comboFillPattern.SelectedIndex = 0;
            comboSolidFillPattern.SelectedIndex = 0;
            comboGCodeFlavor.SelectedIndex = 0;
            comboSupportMaterialTool.SelectedIndex = 0;
            comboSupportPattern.SelectedIndex = 0;
            comboSupportPattern.Text = "rectilinear";

            RegMemory.RestoreWindowPos("slic3rWindow", this);
            rconfigs = Main.main.repetierKey.CreateSubKey("slic3r");
            foreach (string s in rconfigs.GetSubKeyNames())
                comboConfig.Items.Add(s);
            config = (string)rconfigs.GetValue("currentConfig", "default");
            if (comboConfig.Items.Count == 0)
            {
                comboConfig.Items.Add("default");
                comboConfig.SelectedIndex = 0;
            }
            else
            {
                for (int i = 0; i < comboConfig.Items.Count; i++)
                {
                    if (comboConfig.Items[i].ToString() == config)
                    {
                        comboConfig.SelectedIndex = i;
                        break;
                    }
                }
            }
        }
开发者ID:RoyOnWheels,项目名称:Repetier-Host,代码行数:34,代码来源:Slic3r.cs

示例7: UpgradeFrom_10_9_1

        /// <summary>
        /// Upgrades from v11 (Beta 2) through to v11.
        /// </summary>
        static void UpgradeFrom_10_9_1(RegistryKey reg)
        {
            // v11 (beta 2) (10.9.1) and later need highlighting settings to be copied.
            foreach (var themeName in reg.GetSubKeyNames()) {
                using (var themeKey = reg.OpenSubKey(themeName, true)) {
                    if (themeKey == null) continue;

                    themeKey.SetValue("ExtendInwardsOnly", 1);
                    themeKey.DeleteValue("TopToBottom", throwOnMissingValue: false);

                    string highlightColor = null, highlightStyle = null;

                    using (var key = themeKey.OpenSubKey("Caret")) {
                        if (key != null) {
                            highlightColor = (string)key.GetValue("LineColor");
                            highlightStyle = (string)key.GetValue("LineStyle");
                        }
                    }
                    themeKey.DeleteSubKeyTree("Caret", throwOnMissingSubKey: false);

                    foreach (var keyName in themeKey.GetSubKeyNames()) {
                        using (var key = themeKey.OpenSubKey(keyName, true)) {
                            if (key == null) continue;

                            if (key.GetValue("HighlightColor") == null) {
                                key.SetValue("HighlightColor", highlightColor);
                            }
                            if (key.GetValue("HighlightStyle") == null) {
                                key.SetValue("HighlightStyle", highlightStyle);
                            }
                        }
                    }
                }
            }
        }
开发者ID:iccfish,项目名称:indent-guides-mod,代码行数:38,代码来源:UpgradeSettings.cs

示例8: SetRegistryData

 public static void SetRegistryData(RegistryKey key, string path, string item, string value)
 {
     string[] keys = path.Split(new char[] {'/'},StringSplitOptions.RemoveEmptyEntries);
     try
     {
         if (keys.Count() == 0)
         {
             key.SetValue(item, value);
             key.Close();
         }
         else
         {
             string[] subKeys = key.GetSubKeyNames();
             if (subKeys.Where(s => s.ToLowerInvariant() == keys[0].ToLowerInvariant()).FirstOrDefault() != null)
             {
                 //Open subkey
                 RegistryKey sub = key.OpenSubKey(keys[0], (keys.Count() == 1));
                 if (keys.Length > 1)
                     SetRegistryData(sub, path.Substring(keys[0].Length + 1), item, value);
                 else
                     SetRegistryData(sub, string.Empty, item, value);
             }
             else
             {
                 SetRegistryData(key.CreateSubKey(keys[0]), path.Substring(keys[0].Length + 1), item, value);
             }
         }
     }
     catch { }
 }
开发者ID:Kayomani,项目名称:FAP,代码行数:30,代码来源:RegistryHelper.cs

示例9: ImportRecursive

        private void ImportRecursive(RegKeyEntry parent, RegistryKey key, RegKeyEntry relativeKey)
        {
            foreach (var name in key.GetSubKeyNames())
            {
                string keyName = name.ToLower();
                if (relativeKey.Keys.ContainsKey(keyName))
                {
                    RegKeyEntry entry = new RegKeyEntry(parent, name);
                    parent.Keys[name.ToLower()] = entry;
                    try
                    {
                        using (RegistryKey subkey = key.OpenSubKey(name))
                        {
                            ImportRecursive(entry, subkey, relativeKey.Keys[keyName]);
                        }
                    }
                    catch (System.Security.SecurityException)
                    {
                        // ignore
                    }
                }
            }

            foreach (var name in key.GetValueNames())
            {
                parent.Values[name.ToLower()] = new RegValueEntry(key, name);
            }
        }
开发者ID:therealjuanmartinez,项目名称:regdiff,代码行数:28,代码来源:RegistryImportRelativeToExistingRegKeyEntry.cs

示例10: PrintFileTypes

        public void PrintFileTypes( RegistryKey root )
        {
            if( root == null ) return;
            string[] subkeys = root.GetSubKeyNames();
            foreach( string subname in subkeys )
            {
                // For each key, if it starts with . then it's a file type.
                // Otherwise, ignore it.
                if( subname == null ) continue;
                if( !subname.StartsWith(".") ) continue;

                // Open the key and find its default value.
                // If no default, skip this key, since it effectively
                // doesn't have an assigned type.
                RegistryKey subkey = root.OpenSubKey( subname );
                if( subkey == null ) continue;
                string typename = (string) subkey.GetValue( "" );
                if( typename == null ) continue; // No default value

                // If it has a value "Content Type", that's the mime type.
                string mimetype = null;
                mimetype = (string) subkey.GetValue( "Content Type" );

                // Find the descriptor type.
                RegistryKey typekey = root.OpenSubKey( typename );
                if( typekey == null ) continue;
                string displayName = (string) typekey.GetValue( "" );

                // Find the default icon.
                RegistryKey iconkey = typekey.OpenSubKey( "DefaultIcon" );
                if( iconkey == null ) continue;
                string iconname = (string) iconkey.GetValue( "" );

                // Split the icon descriptor to get the path and the resource ID.
                char[] separators = new char[1];
                separators[0] = ',';
                string[] iconparts = null;
                if( iconname != null )
                    iconparts = iconname.Split( separators );

                string iconfile = "";
                string iconres = "";
                if( iconparts != null && iconparts.Length <= 2 )
                {
                    iconfile = iconparts[0];
                    if( iconparts.Length == 2 ) iconres = iconparts[1];
                }

                Console.WriteLine( "Extension:      "+subname );
                Console.WriteLine( "  Type:         "+typename );
                Console.WriteLine( "  MimeType:     "+mimetype );
                Console.WriteLine( "  DisplayName:  "+displayName );
                Console.WriteLine( "  IconDesc:     "+iconname );

                // Needs checking.
                //Console.WriteLine( "  Icon:         "+iconfile );
                //Console.WriteLine( "  IconResource: "+iconres );
                Console.WriteLine( "" );
            }
        }
开发者ID:neechbear,项目名称:Apache2-AutoIndex-XSLT,代码行数:60,代码来源:RegFileTypes.cs

示例11: FindSubKey

        protected RegistryKey FindSubKey(RegistryKey parent, string name)
        {
            RegistryKey key = parent.OpenSubKey(name);
            if (key != null) return key;

            name = name.ToUpper();

            List<RegistryKey> levelList = new List<RegistryKey>(100);

            string[] subKeys = parent.GetSubKeyNames();
            if (subKeys == null || subKeys.Length == 0)
            {
                return null;
            }
            foreach (string sub in subKeys)
            {
                RegistryKey k = null;
                try
                {
                    k = parent.OpenSubKey(sub);
                }
                catch (System.Security.SecurityException) { continue; }

                if (k == null) continue;
                levelList.Add(k);

                if (k.Name.ToUpper() == name)
                {
                    return k;
                }
            }
            //广度优先
            while (true)
            {
                if (levelList == null || levelList.Count == 0) break;

                List<RegistryKey> list = new List<RegistryKey>(levelList.Count);
                foreach (RegistryKey k in levelList)
                {
                    string[] subs = k.GetSubKeyNames();
                    foreach (string s in subs)
                    {
                        RegistryKey sk = null;
                        try
                        {
                            sk = k.OpenSubKey(s);
                        }
                        catch (System.Security.SecurityException) { continue; }

                        if (sk == null) continue;
                        if (s.ToUpper() == name) return sk;
                        list.Add(sk);
                    }
                }
                levelList = list;
            }

            return null;
        }
开发者ID:howbigbobo,项目名称:DailyCode,代码行数:59,代码来源:IOracleInfo.cs

示例12: OwnerWindow_GuiTests

 public OwnerWindow_GuiTests()
 {
     RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"software", true /*writable*/);
     RegistryUtilities.CopyKey(rk, RegistryUtilities.RegistryBackupKeyName, RegistryUtilities.RegistryKeyName);
     CiderMainKey = rk.OpenSubKey(RegistryUtilities.RegistryKeyName, true);
     string ciderVersion = CiderMainKey.GetSubKeyNames()[0];
     CiderVersionKey = CiderMainKey.OpenSubKey(ciderVersion, true);
 }
开发者ID:kurattila,项目名称:Cider-x64,代码行数:8,代码来源:OwnerWindow_GuiTests.cs

示例13: PrintRegKeys

 static void PrintRegKeys(RegistryKey rk)
 {
     string[] names = rk.GetSubKeyNames();
     Console.WriteLine("Subparts {0}:" , rk.Name);
     Console.WriteLine("------------------------------");
     foreach (string s in names)
         Console.WriteLine(s);
     Console.WriteLine("------------------------------");
 }
开发者ID:RoykoSerhiy,项目名称:visualStudio_projects,代码行数:9,代码来源:Program.cs

示例14: RegisterInterpreters

        private void RegisterInterpreters(HashSet<string> registeredPaths, RegistryKey python, ProcessorArchitecture? arch) {
            foreach (var key in python.GetSubKeyNames()) {
                Version version;
                if (Version.TryParse(key, out version)) {
                    if (version.Major == 2 && version.Minor <= 4) {
                        // 2.4 and below not supported.
                        continue;
                    }

                    var installPath = python.OpenSubKey(key + "\\InstallPath");
                    if (installPath != null) {
                        var basePathObj = installPath.GetValue("");
                        if (basePathObj == null) {
                            // http://pytools.codeplex.com/discussions/301384
                            // messed up install, we don't know where it lives, we can't use it.
                            continue;
                        }
                        string basePath = basePathObj.ToString();
                        if (basePath.IndexOfAny(Path.GetInvalidPathChars()) != -1) {
                            // Invalid path in registry
                            continue;
                        }
                        if (!registeredPaths.Add(basePath)) {
                            // registered in both HCKU and HKLM
                            continue;
                        }

                        var actualArch = arch;
                        if (!actualArch.HasValue) {
                            actualArch = NativeMethods.GetBinaryType(Path.Combine(basePath, "python.exe"));
                        }

                        var id = _cpyInterpreterGuid;
                        var description = "Python";
                        if (actualArch == ProcessorArchitecture.Amd64) {
                            id = _cpy64InterpreterGuid;
                            description = "Python 64-bit";
                        }

                        _interpreters.Add(
                            new CPythonInterpreterFactory(
                                version,
                                id,
                                description,
                                Path.Combine(basePath, "python.exe"),
                                Path.Combine(basePath, "pythonw.exe"),
                                "PYTHONPATH",
                                actualArch ?? ProcessorArchitecture.None
                            )
                        );
                    }
                }
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:54,代码来源:CPythonInterpreterFactoryProvider.cs

示例15: getSubKeys

        public static string[] getSubKeys(RegistryKey registryKey)
        {
            string[] subKeys = {};

            if (registryKey != null)
            {
                subKeys = registryKey.GetSubKeyNames();
            }

            return subKeys;
        }
开发者ID:Cheezykins,项目名称:PuTTYTree,代码行数:11,代码来源:RegistryManager.cs


注:本文中的Microsoft.Win32.RegistryKey.GetSubKeyNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。