• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Win32.RegistryKey类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



RegistryKey类属于Microsoft.Win32命名空间,在下文中一共展示了RegistryKey类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: RegisterFile

        private static void RegisterFile(string path, RegistryKey root)
        {
            try
            {
				string userPath = GetUserFilePath(Path.GetFileName(path));
				string assembly = Assembly.GetExecutingAssembly().Location;
                string folder = Path.GetDirectoryName(assembly).ToLowerInvariant();
                string file = Path.Combine(folder, path);

                if (!File.Exists(file))
                    return;

				File.Copy(file, userPath, true);

				using (RegistryKey key = root.OpenSubKey("JavaScriptLanguageService", true))
                {
                    if (key == null)
                        return;

                    key.SetValue("ReferenceGroups_WE", "Implicit (Web)|" + userPath + ";");
                    return;
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }
开发者ID:venux,项目名称:WebEssentials2015,代码行数:28,代码来源:JavaScriptIntellisense.cs


示例2: GetItemsFromRegistry

        protected List<SoftwareDTOResponse> GetItemsFromRegistry(RegistryKey key, string path)
        {
            List<SoftwareDTOResponse> software = new List<SoftwareDTOResponse>();

            using (RegistryKey rk = key.OpenSubKey(path))
            {
                foreach (string skName in rk.GetSubKeyNames())
                {
                    using (RegistryKey sk = rk.OpenSubKey(skName))
                    {
                        try
                        {
                            SoftwareDTOResponse application = new SoftwareDTOResponse();
                            application.Label = sk.GetValue("DisplayName").ToString();
                            application.ModelName = application.Label;
                            application.Version = sk.GetValue("DisplayVersion").ToString();
                            application.Path = sk.GetValue("Publisher").ToString() +
                                               " - " +
                                               application.Label +
                                               " - " +
                                               application.Version;

                            software.Add(application);
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
            return software;
        }
开发者ID:jjagodzinski,项目名称:ralph,代码行数:32,代码来源:WindowsRegistryDetectorSource.cs


示例3: Add

 public AddinsKey Add(string name, RegistryKey rootPath, string registryPath)
 {
     AddinsKey newItem = new AddinsKey(_parent, name, rootPath, registryPath);
     _items.Add(newItem);
     _parent.StopFlag = false;
     return newItem;
 }
开发者ID:netintellect,项目名称:NetOffice,代码行数:7,代码来源:AddinItems.cs


示例4: ChatOptions

        public ChatOptions()
        {
            RegistryKey key = Registry.CurrentUser.OpenSubKey("Software", true);
            m_reg = key.CreateSubKey("TwitchChatClient");

            m_iniReader = new IniReader("options.ini");

            IniSection section = m_iniReader.GetSectionByName("stream");
            if (section == null)
                throw new InvalidOperationException("Options file missing [Stream] section.");

            m_stream = section.GetValue("stream");
            m_user = section.GetValue("twitchname") ?? section.GetValue("user") ?? section.GetValue("username");
            m_oath = section.GetValue("oauth") ?? section.GetValue("pass") ?? section.GetValue("password");

            section = m_iniReader.GetSectionByName("highlight");
            List<string> highlights = new List<string>();
            if (section != null)
                foreach (string line in section.EnumerateRawStrings())
                    highlights.Add(DoReplacements(line.ToLower()));

            m_highlightList = highlights.ToArray();

            section = m_iniReader.GetSectionByName("ignore");
            if (section != null)

            m_ignore = new HashSet<string>((from s in section.EnumerateRawStrings()
                                            where !string.IsNullOrWhiteSpace(s)
                                            select s.ToLower()));
        }
开发者ID:NitroXenon,项目名称:WinterBot,代码行数:30,代码来源:ChatOptions.cs


示例5: PopulateOptions

 // populates an options object from values stored in the registry
 private static void PopulateOptions(object options, RegistryKey key)
 {
     foreach (PropertyInfo propInfo in options.GetType().GetProperties())
     {
         if (propInfo.IsDefined(typeof(ApplyPolicyAttribute)))
         {
             object valueFromRegistry = key.GetValue(propInfo.Name);
             if (valueFromRegistry != null)
             {
                 if (propInfo.PropertyType == typeof(string))
                 {
                     propInfo.SetValue(options, Convert.ToString(valueFromRegistry, CultureInfo.InvariantCulture));
                 }
                 else if (propInfo.PropertyType == typeof(int))
                 {
                     propInfo.SetValue(options, Convert.ToInt32(valueFromRegistry, CultureInfo.InvariantCulture));
                 }
                 else if (propInfo.PropertyType == typeof(Type))
                 {
                     propInfo.SetValue(options, Type.GetType(Convert.ToString(valueFromRegistry, CultureInfo.InvariantCulture), throwOnError: true));
                 }
                 else
                 {
                     throw CryptoUtil.Fail("Unexpected type on property: " + propInfo.Name);
                 }
             }
         }
     }
 }
开发者ID:leloulight,项目名称:DataProtection,代码行数:30,代码来源:RegistryPolicyResolver.cs


示例6: DeleteSubKeyTree

 /// <summary>
 /// Helper function to recursively delete a sub-key (swallows errors in the
 /// case of the sub-key not existing
 /// </summary>
 /// <param name="root">Root to delete key from</param>
 /// <param name="subKey">Name of key to delete</param>
 public static void DeleteSubKeyTree(RegistryKey root, string subKey)
 {
     // delete the specified sub-key if if exists (swallow the error if the
     // sub-key does not exist)
     try { root.DeleteSubKeyTree(subKey); }
     catch (ArgumentException) { }
 }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:13,代码来源:RegistryHelper.cs


示例7: PackageInfo

        internal PackageInfo(RegistryKey key)
        {
            PackageId = Path.GetFileName(key.Name);
            DisplayName = (string)key.GetValue("DisplayName");
            PackageRootFolder = (string)key.GetValue("PackageRootFolder");

            // walk the files...
            XamlFiles = new List<string>();
            JsFiles = new List<string>();
            WalkFiles(new DirectoryInfo(PackageRootFolder));

            // probe for a start page...
            var appKey = key.OpenSubKey("Applications");
            if (appKey != null)
            {
                using (appKey)
                {
                    foreach(var subAppName in appKey.GetSubKeyNames())
                    {
                        using (var subAppKey = appKey.OpenSubKey(subAppName))
                        {
                            if (subAppKey != null)
                            {
                                var start = (string)subAppKey.GetValue("DefaultStartPage");
                                if (!(string.IsNullOrEmpty(start)))
                                {
                                    FoundStartPage = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:ZeroInfinite,项目名称:XamlOrHtml,代码行数:35,代码来源:PackageInfo.cs


示例8: WriteToRegistry

		static public void WriteToRegistry(RegistryKey RegHive, string RegPath, string KeyName, string KeyValue)
		{
			// Split the registry path
			string[] regStrings;
			regStrings = RegPath.Split('\\');
			// First item of array will be the base key, so be carefull iterating below
			RegistryKey[] RegKey = new RegistryKey[regStrings.Length + 1];
			RegKey[0] = RegHive;

			for( int i = 0; i < regStrings.Length; i++ )
			{
				RegKey[i + 1] = RegKey[i].OpenSubKey(regStrings[i], true);
				// If key does not exist, create it
				if (RegKey[i + 1] == null)
				{
					RegKey[i + 1] = RegKey[i].CreateSubKey(regStrings[i]);
				}
			}

			// Write the value to the registry
			try
			{
				RegKey[regStrings.Length].SetValue(KeyName, KeyValue);
			}
			catch (System.NullReferenceException)
			{
				throw(new Exception("Null Reference"));
			}
			catch (System.UnauthorizedAccessException)
			{
				throw(new Exception("Unauthorized Access"));
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:33,代码来源:RegistryUtil.cs


示例9: GetRegistryStringValue

 public static string GetRegistryStringValue(RegistryKey baseKey, string strSubKey, string strValue)
 {
     object obj = null;
     string text = string.Empty;
     string result;
     try
     {
         RegistryKey registryKey = baseKey.OpenSubKey(strSubKey);
         if (registryKey == null)
         {
             result = null;
             return result;
         }
         obj = registryKey.GetValue(strValue);
         if (obj == null)
         {
             result = null;
             return result;
         }
         registryKey.Close();
         baseKey.Close();
     }
     catch (Exception ex)
     {
         text = ex.Message;
         result = null;
         return result;
     }
     result = obj.ToString();
     return result;
 }
开发者ID:Padungsak,项目名称:efinTradePlus,代码行数:31,代码来源:BusinessServiceFactory.cs


示例10: UninstallerObject

 public UninstallerObject(RegistryKey rootKey, string keyPath, string keyName)
 {
     using (RegistryKey hkKey = rootKey.OpenSubKey(keyPath, false))
     {
         string ApplicationName = hkKey.GetValue("DisplayName") as string;
         if (string.IsNullOrEmpty(ApplicationName))
         {
             ApplicationName = hkKey.GetValue("QuietDisplayName") as string;
         }
         if (string.IsNullOrEmpty(ApplicationName))
             ApplicationName = keyName;
         Objects[(int)UninstallerItemTypes.Application] = ApplicationName;
         Objects[(int)UninstallerItemTypes.Path] = hkKey.GetValue("InstallLocation") as string;
         Objects[(int)UninstallerItemTypes.Key] = keyName;
         Objects[(int)UninstallerItemTypes.Version] = hkKey.GetValue("DisplayVersion") as string;
         Objects[(int)UninstallerItemTypes.Publisher] = hkKey.GetValue("Publisher") as string;
         Objects[(int)UninstallerItemTypes.HelpLink] = hkKey.GetValue("HelpLink") as string;
         Objects[(int)UninstallerItemTypes.AboutLink] = hkKey.GetValue("URLInfoAbout") as string;
         ToolTipText = hkKey.GetValue("UninstallString") as string;
         Objects[(int)UninstallerItemTypes.Action] = ToolTipText;
         if (string.IsNullOrEmpty(ToolTipText))
         {
             ForegroundColor = Color.Gray;
         }
         else if (!string.IsNullOrEmpty(Path))
         {
             ForegroundColor = Color.Blue;
         }
     }
 }
开发者ID:zippy1981,项目名称:GTools,代码行数:30,代码来源:UninstallerObject.cs


示例11: 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


示例12: 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


示例13: UninstallerDataObject

 public UninstallerDataObject(RegistryKey rootKey, string keyPath, string keyName)
     : base(keyName)
 {
     BasedInLocalMachine = (rootKey == Registry.LocalMachine);
     Refresh(rootKey, keyPath, keyName);
     ConstructionIsFinished = true;
 }
开发者ID:johnhk,项目名称:pserv4,代码行数:7,代码来源:UninstallerDataObject.cs


示例14: 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


示例15: GetDotNetVersion

        /// <summary>
        /// Get framework version for specified SubKey
        /// </summary>
        /// <param name="parentKey"></param>
        /// <param name="subVersionName"></param>
        /// <param name="versions"></param>
        private static void GetDotNetVersion(RegistryKey parentKey, string subVersionName, IList<NetFrameworkVersionInfo> versions)
        {
            if (parentKey != null)
            {
                string installed = Convert.ToString(parentKey.GetValue("Install"));

                if (installed == "1")
                {
                    NetFrameworkVersionInfo versionInfo = new NetFrameworkVersionInfo();

                    versionInfo.VersionString = Convert.ToString(parentKey.GetValue("Version"));

                    var test = versionInfo.BaseVersion;

                    versionInfo.InstallPath = Convert.ToString(parentKey.GetValue("InstallPath"));
                    versionInfo.ServicePackLevel = Convert.ToInt32(parentKey.GetValue("SP"));

                    if (parentKey.Name.Contains("Client"))
                        versionInfo.FrameworkProfile = "Client Profile";
                    else if (parentKey.Name.Contains("Full"))
                        versionInfo.FrameworkProfile = "Full Profile";

                    if (!versions.Contains(versionInfo))
                        versions.Add(versionInfo);
                }
            }
        }
开发者ID:steve600,项目名称:VersatileMediaManager,代码行数:33,代码来源:DotNetFrameworkInfo.cs


示例16: Check

        protected override void Check(MainForm form, string ext, RegistryKey rk, DataEntry[] de)
        {
            RegistryKey r = null;

            using (r = Registry.ClassesRoot.OpenSubKey(string.Format(CultureInfo.InvariantCulture, "{0}\\ShellEx\\{1}", ext, ShellExGuid)))
            {
                CheckValue(form, r, null, new string[] { ThumnailCacheGuid }, de);
            }

            if (r == null)
            {
                using (r = Registry.ClassesRoot.OpenSubKey(string.Format(CultureInfo.InvariantCulture, "SystemFileAssociations\\{0}\\ShellEx\\{1}", ext, ShellExGuid)))
                {
                    CheckValue(form, r, null, new string[] { ThumnailCacheGuid }, de);
                }
            }

            if (r == null)
            {
                string type = CheckStringValue(form, rk, PerceivedType, de);

                using (r = OpenSubKey(form, Registry.ClassesRoot, string.Format(CultureInfo.InstalledUICulture, "SystemFileAssociations\\{0}\\ShellEx\\{1}", type, ShellExGuid), de))
                {
                    CheckValue(form, r, null, new string[] { ThumnailCacheGuid }, de);
                }
            }
        }
开发者ID:eakova,项目名称:resizer,代码行数:27,代码来源:ThumnailCacheIntegrationRule.cs


示例17: GetDword

		public static Int32? GetDword( RegistryKey rk, string value, Int32? defaultValue = null ) {
			var result = rk.GetValue( value ) as Int32?;
			if( null == result && null != defaultValue ) {
				result = defaultValue;
			}
			return result;
		}
开发者ID:beached,项目名称:RemoteWinAdmin,代码行数:7,代码来源:RegistryHelpers.cs


示例18: RenameSubKey

 /// <summary>
 /// Renames a subkey of the passed in registry key since 
 /// the Framework totally forgot to include such a handy feature.
 /// </summary>
 /// <param name="regKey">The RegistryKey that contains the subkey 
 /// you want to rename (must be writeable)</param>
 /// <param name="subKeyName">The name of the subkey that you want to rename
 /// </param>
 /// <param name="newSubKeyName">The new name of the RegistryKey</param>
 /// <returns>True if succeeds</returns>
 public static bool RenameSubKey(RegistryKey parentKey,
     string subKeyName, string newSubKeyName)
 {
     CopyKey(parentKey, subKeyName, newSubKeyName);
     parentKey.DeleteSubKeyTree(subKeyName);
     return true;
 }
开发者ID:Cocotus,项目名称:OutlookProfileEditor,代码行数:17,代码来源:RenameRegistry.cs


示例19: ReadIntKeyValue

		private static int ReadIntKeyValue(RegistryKey registryKey, string keyName, string valueName)
		{
			using (var key = registryKey.OpenSubKey(keyName))
			{
				return key == null ? 0 : (int)key.GetValue(valueName, 0);
			}
		}
开发者ID:manuc66,项目名称:ApprovalTests.Net,代码行数:7,代码来源:WindowsRegistryAssert.cs


示例20: RegEntryExists

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Checks if a registry value exists.
		/// </summary>
		/// <param name="key">The base registry key of the key to check</param>
		/// <param name="subKey">Name of the group key, or string.Empty if there is no 
		/// groupKeyName.</param>
		/// <param name="regEntry">The name of the registry entry.</param>
		/// <param name="value">[out] value of the registry entry if it exists; null otherwise.</param>
		/// <returns><c>true</c> if the registry entry exists, otherwise <c>false</c></returns>
		/// ------------------------------------------------------------------------------------
		public static bool RegEntryExists(RegistryKey key, string subKey, string regEntry, out object value)
		{
			value = null;

            if (key == null)
                return false;

            if (string.IsNullOrEmpty(subKey))
			{
				value = key.GetValue(regEntry);
				if (value != null)
					return true;
				return false;
			}

			if (!KeyExists(key, subKey))
				return false;

			using (RegistryKey regSubKey = key.OpenSubKey(subKey))
			{
				Debug.Assert(regSubKey != null, "Should have caught this in the KeyExists call above");
				if (Array.IndexOf(regSubKey.GetValueNames(), regEntry) >= 0)
				{
					value = regSubKey.GetValue(regEntry);
					return true;
				}

				return false;
			}
		}
开发者ID:neilmayhew,项目名称:pathway,代码行数:41,代码来源:RegistryHelperLite.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Win32.SaveFileDialog类代码示例发布时间:2022-05-26
下一篇:
C# Win32.PowerModeChangedEventArgs类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap