本文整理汇总了C#中Microsoft.Win32.RegistryKey.GetSubKeyNames方法的典型用法代码示例。如果您正苦于以下问题:C# RegistryKey.GetSubKeyNames方法的具体用法?C# RegistryKey.GetSubKeyNames怎么用?C# RegistryKey.GetSubKeyNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Win32.RegistryKey
的用法示例。
在下文中一共展示了RegistryKey.GetSubKeyNames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: foreach
// Print the information from the Test9999 subkey.
Console.WriteLine("There are {0} subkeys under {1}.",
test9999.SubKeyCount.ToString(), test9999.Name);
foreach(string subKeyName in test9999.GetSubKeyNames())
{
using(RegistryKey
tempKey = test9999.OpenSubKey(subKeyName))
{
Console.WriteLine("\nThere are {0} values for {1}.",
tempKey.ValueCount.ToString(), tempKey.Name);
foreach(string valueName in tempKey.GetValueNames())
{
Console.WriteLine("{0,-8}: {1}", valueName,
tempKey.GetValue(valueName).ToString());
}
}
}
示例2: RegistryKey.GetSubKeyNames()
//引入命名空间
using System;
using Microsoft.Win32;
class MainClass
{
public static void SearchSubKeys(RegistryKey root, String searchKey)
{
foreach (string keyname in root.GetSubKeyNames())
{
try
{
using (RegistryKey key = root.OpenSubKey(keyname))
{
if (keyname == searchKey)
Console.WriteLine("Registry key found : {0} contains {1} values",
key.Name, key.ValueCount);
SearchSubKeys(key, searchKey);
}
}
catch (System.Security.SecurityException)
{
}
}
}
public static void Main(String[] args)
{
using (RegistryKey root = Registry.CurrentUser)
{
string myKey="Java";
SearchSubKeys(root, myKey);
}
}
}