當前位置: 首頁>>代碼示例>>C#>>正文


C# RegistryKey.GetValueNames方法代碼示例

本文整理匯總了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]));
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:27,代碼來源:SerializableRegistryKey.cs

示例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;
        }
開發者ID:vipul0092,項目名稱:FileSplitter,代碼行數:35,代碼來源:RegAccess.cs

示例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 { }
        }
開發者ID:raven-ie,項目名稱:MASGAU,代碼行數:32,代碼來源:PCAnalyzer.cs

示例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());
 }
開發者ID:JamesLinus,項目名稱:sharpshell,代碼行數:10,代碼來源:RegistryKeyItem.cs

示例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 = "";
        }
開發者ID:4g0st1n0,項目名稱:MapManager,代碼行數:10,代碼來源:AddFontForm.cs

示例6: GetValuesFromRegistryKey

        /// <summary>
        /// Gets all the values from a given Microsoft.Win32.RegistryKey
        /// object as a System.Collections.Generic.Dictionary&lt;string, object&gt;,
        /// 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;
        }
開發者ID:allex,項目名稱:toolkit,代碼行數:19,代碼來源:Registry.cs

示例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;
     }
 }
開發者ID:wangan,項目名稱:BingWallpaper,代碼行數:15,代碼來源:AutoStart.cs

示例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;
            }
        }
開發者ID:virmitio,項目名稱:TempRepo,代碼行數:46,代碼來源:RegistryComparison.cs

示例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();
 }
開發者ID:dalinhuang,項目名稱:wdeqawes-efrwserd-rgtedrtf,代碼行數:46,代碼來源:FormSearch.cs

示例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;
 }
開發者ID:2594636985,項目名稱:SharpDevelop,代碼行數:21,代碼來源:ComCatRootTreeNode.cs

示例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);
            }
        }
開發者ID:zhaojunlucky,項目名稱:broken_heart,代碼行數:20,代碼來源:RegHelper.cs

示例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);
            }
        }
開發者ID:Cocotus,項目名稱:OutlookProfileEditor,代碼行數:20,代碼來源:RenameRegistry.cs

示例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);
            }
        }
開發者ID:abhishek-kumar,項目名稱:AIGA,代碼行數:22,代碼來源:frmServices2.cs

示例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);
            }
        }
開發者ID:JacekWojciechowski,項目名稱:ImageGlass,代碼行數:22,代碼來源:RegistryUtilities.cs

示例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;
        }
開發者ID:Cheezykins,項目名稱:PuTTYTree,代碼行數:23,代碼來源:RegistryManager.cs


注:本文中的Microsoft.Win32.RegistryKey.GetValueNames方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。