本文整理汇总了C#中Microsoft.Win32.RegistryKey.GetValueNames方法的典型用法代码示例。如果您正苦于以下问题:C# RegistryKey.GetValueNames方法的具体用法?C# RegistryKey.GetValueNames怎么用?C# RegistryKey.GetValueNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Win32.RegistryKey
的用法示例。
在下文中一共展示了RegistryKey.GetValueNames方法的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]));
}
}
示例2: GetExtInfo
public static string[] GetExtInfo(string extension)
{
string keyval=""; string[] retInfo = new string[2];
using (sysreg = Registry.ClassesRoot.OpenSubKey(extension))
{
string[] keys = sysreg.GetValueNames();
foreach (string key in keys)
{
if (key == null || key == "") { keyval = (string)sysreg.GetValue(key, ""); break; }
}
}
if (keyval == null || keyval == "") { retInfo[1] = (extension.Remove(0, 1)).ToUpper() + " File"; retInfo[0] = "Other"; }
else if (keyval.Contains(',')) { retInfo[0] = keyval; retInfo[1] = (extension.Remove(0, 1)).ToUpper() + " File"; }
else
{
using (sysreg = Registry.ClassesRoot.OpenSubKey(keyval))
{
string[] keys = sysreg.GetValueNames();
foreach (string key in keys)
{
if (key == null || key == "") { retInfo[1] = (string)sysreg.GetValue(key); break; }
}
}
using(sysreg = Registry.ClassesRoot.OpenSubKey(keyval + "\\DefaultIcon"))
{
string[] keys = sysreg.GetValueNames();
foreach (string key in keys)
{
if (key == null || key == "") { retInfo[0] = (string)sysreg.GetValue(key); break; }
}
}
}
return retInfo;
}
示例3: registryTraveller
private void registryTraveller(RegistryKey look_here)
{
if (worker.CancellationPending)
return;
foreach (string check_me in look_here.GetValueNames()) {
RegistryKeyValue value = new RegistryKeyValue();
try {
value.key = look_here.Name;
value.value = check_me;
if (look_here.GetValue(check_me) != null) {
value.data = look_here.GetValue(check_me).ToString();
if (value.data.Length >= path.FullDirPath.Length && path.FullDirPath.ToLower() == value.data.Substring(0, path.FullDirPath.Length).ToLower()) {
outputLine(Environment.NewLine + "Key:" + value.key);
outputLine("Value: " + value.value);
output("Data: ");
outputPath(value.data);
}
}
} catch { }
}
try {
RegistryKey sub_key;
foreach (string check_me in look_here.GetSubKeyNames()) {
try {
sub_key = look_here.OpenSubKey(check_me);
if (sub_key != null)
registryTraveller(sub_key);
} catch (System.Security.SecurityException) { }
}
} catch { }
}
示例4: RegistryKeyItem
public RegistryKeyItem(RegistryKey hiveKey, string displayName)
{
this.hiveKey = hiveKey;
this.displayName = displayName;
lazyChildKeys = new Lazy<List<RegistryKeyItem>>(CreateChildKeys);
lazyAttributes = new Lazy<List<KeyAttribute>>(() =>
hiveKey.GetValueNames().Select(valueName =>
new KeyAttribute(valueName, hiveKey.GetValue(valueName).ToString())).ToList());
}
示例5: AddFontForm
public AddFontForm()
{
InitializeComponent();
fontsKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\Fonts");
foreach (string font in fontsKey.GetValueNames())
if (font.EndsWith("(TrueType)"))
comboBoxFonts.Items.Add(font);
fontFile = "";
}
示例6: GetValuesFromRegistryKey
/// <summary>
/// Gets all the values from a given Microsoft.Win32.RegistryKey
/// object as a System.Collections.Generic.Dictionary<string, object>,
/// with the dictionary key being the value name, and the dictionary value being the
/// registry value.
/// </summary>
/// <param name="rk">RegistryKey to retrieve values from.</param>
public static Dictionary<string, object> GetValuesFromRegistryKey(RegistryKey rk)
{
Dictionary<string, object> dict = new Dictionary<string, object>();
string[] names = rk.GetValueNames();
foreach (string name in names) {;
dict.Add(name, rk.GetValue(name));
}
return dict;
}
示例7: Check
public static bool Check(RegistryKey runKey, string appName)
{
try {
string[] runList = runKey.GetValueNames();
foreach (string item in runList) {
if (item.Equals(appName))
return true;
}
return false;
}
catch (Exception ex) {
EventLog.WriteEntry("BW", ex.Message, EventLogEntryType.Error);
return false;
}
}
示例8: InnerCompare
private static bool InnerCompare(RegistryKey A, RegistryKey B, string root,ref Dictionary<string, Data> output)
{
bool current = true;
try
{
if (A != null)
{
// Process A
foreach (var Name in A.GetValueNames())
{
string EntryName = root + A.Name + "::" + Name;
var dat = new Data();
dat.SetA(A.GetValue(Name), A.GetValueKind(Name));
output.Add(EntryName, dat);
}
foreach (var keyName in A.GetSubKeyNames())
{
RegistryKey subA = A.OpenSubKey(keyName);
RegistryKey subB = B == null ? null : B.OpenSubKey(keyName);
current &= InnerCompare(subA, subB, root + keyName + @"\", ref output);
}
}
if (B != null)
{
foreach (var Name in B.GetValueNames())
{
string EntryName = root + B.Name + "::" + Name;
Data dat = output.ContainsKey(EntryName) ? output[EntryName] : new Data();
dat.SetB(B.GetValue(Name), B.GetValueKind(Name));
output[EntryName] = dat;
}
foreach (var keyName in B.GetSubKeyNames())
{
// when we get here, we have already cleared everything present in the A side
RegistryKey subB = B.OpenSubKey(keyName);
current &= InnerCompare(null, subB, root + keyName + @"\", ref output);
}
}
return current;
}
catch (Exception e)
{
return false;
}
}
示例9: SearchRegistryKey
/// 搜索注册表指定项
/// <param name="key">注册表项</param>
private void SearchRegistryKey(RegistryKey key)
{
if (key == null) return; //判断项是否为空
//获取注册表项的键名列表
string[] valueNames = key.GetValueNames();
//将注册表项加入到搜索状态提示中
SetSearchState(key.ToString());
//遍历所有键名,判断键名或键值中是否含有搜索的关键字
foreach (string valueName in valueNames)
{
//搜索的关键字
string keywords = tBKeywords.Text;
//获取键值并转换成字符串类型
string value = key.GetValue(valueName).ToString();
//判断键名或键值中是否含有搜索的关键字
if (valueName.Contains(keywords)
|| value.Contains(keywords))
{//如果含有搜索关键字
//将该键在注册表中的全路径添加到搜索结果列表中
AddSearchState(key.ToString() + "\\" + valueName);
}
}
//获取项的所有子项名
string[] subKeyNames = key.GetSubKeyNames();
//遍历所有子项,并对其进行搜索
foreach (string subKeyName in subKeyNames)
{
try
{
//根据子项名获取子项
RegistryKey subKey = key.OpenSubKey(subKeyName);
//如果子项为空,则继续搜索下一子项
if (subKey == null) continue;
//搜索子项
SearchRegistryKey(subKey);
}
catch (Exception)
{
//如果由于权限问题无法访问子项,则继续搜索下一子项
continue;
}
}
key.Close();
}
示例10: ProcessChild
// Used to get the basic info that is used by this type
// of node
protected override Object ProcessChild(RegistryKey key,
String subKeyName)
{
BasicInfo info = new BasicInfo(key, subKeyName);
foreach (String valueName in key.GetValueNames())
{
if (valueName != null &&
!valueName.Equals("") &&
info.Name == null)
info.Name = (String)key.GetValue(valueName);
}
if (info.Name == null)
{
info.Name = subKeyName;
info.PrintName = subKeyName + " (guid)";
}
info._infoType = "Category";
return info;
}
示例11: listAllKeys
public static Dictionary<string, string> listAllKeys(RegistryKey registryKey)
{
try
{
Dictionary<string, string> regKeyValues = new Dictionary<string, string>();
string[] keys = registryKey.GetValueNames();
foreach (string key in keys)
{
object value = registryKey.GetValue(key);
regKeyValues.Add(key, value == null? null : value.ToString());
}
return regKeyValues;
}
catch(Exception e)
{
throw new RegException(e);
}
}
示例12: RecurseCopyKey
private static void RecurseCopyKey(RegistryKey sourceKey, RegistryKey destinationKey)
{
//copy all the values
foreach (string valueName in sourceKey.GetValueNames())
{
object objValue = sourceKey.GetValue(valueName);
RegistryValueKind valKind = sourceKey.GetValueKind(valueName);
destinationKey.SetValue(valueName, objValue, valKind);
}
//For Each subKey
//Create a new subKey in destinationKey
//Call myself
foreach (string sourceSubKeyName in sourceKey.GetSubKeyNames())
{
RegistryKey sourceSubKey = sourceKey.OpenSubKey(sourceSubKeyName);
RegistryKey destSubKey = destinationKey.CreateSubKey(sourceSubKeyName);
RecurseCopyKey(sourceSubKey, destSubKey);
}
}
示例13: frmServices2
public frmServices2(frmServices.ServicesUIText uiText, RegistryKey key)
{
InitializeComponent();
this.serviceText = uiText;
serviceRegKey = key;
this.Text = uiText.ConfigText;
this.labelServiceList.Text = uiText.MyServicesText;
this.lblAddService.Text = uiText.AddServiceText;
this.lblExample.Text = uiText.ExampleText;
// Add all of the existing service hosts - lower case (case insensitive)
string[] serviceHosts = serviceRegKey.GetValueNames();
currentServices = new ArrayList();
foreach (string host in serviceHosts)
{
string lowerHost = host.ToLower();
currentServices.Add(lowerHost);
listBoxServices.Items.Add(lowerHost);
}
}
示例14: RecurseCopyKey
private void RecurseCopyKey(RegistryKey sourceKey, RegistryKey destinationKey)
{
//copy all the values
foreach (string valueName in sourceKey.GetValueNames())
{
object objValue = sourceKey.GetValue(valueName);
RegistryValueKind valKind = sourceKey.GetValueKind(valueName);
destinationKey.SetValue(valueName, objValue, valKind);
}
//For Each subKey
//Create a new subKey in destinationKey
//Call myself
foreach (string sourceSubKeyName in sourceKey.GetSubKeyNames())
{
RegistryKey sourceSubKey = sourceKey.OpenSubKey(sourceSubKeyName,
RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.FullControl);
RegistryKey destSubKey = destinationKey.CreateSubKey(sourceSubKeyName,
RegistryKeyPermissionCheck.ReadWriteSubTree);
RecurseCopyKey(sourceSubKey, destSubKey);
}
}
示例15: getSession
public static Session getSession(RegistryKey registryKey)
{
var ret = new Session();
if (registryKey != null)
{
var valueKeys = registryKey.GetValueNames();
foreach (var key in valueKeys)
{
var value = new RegistryValue
{
kind = registryKey.GetValueKind(key),
key = key,
value = registryKey.GetValue(key).ToString()
};
ret.Add(value);
}
}
return ret;
}