本文整理匯總了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;
}