当前位置: 首页>>代码示例>>C#>>正文


C# Microsoft.OpenSubKey方法代码示例

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


在下文中一共展示了Microsoft.OpenSubKey方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeleteRegValue

 public static void DeleteRegValue( Microsoft.Win32.RegistryKey hkey, string vname )
 {
     using ( RegistryKey key = hkey.OpenSubKey( RazorRegPath, true ) )
     {
         key.DeleteValue( vname, false );
     }
 }
开发者ID:WildGenie,项目名称:Razor,代码行数:7,代码来源:Config.cs

示例2: ClearReg

 //[RegistryPermissionAttribute(SecurityAction.PermitOnly, Write = @"HKEY_CURRENT_USER\SOFTWARE\DBFConvert")]
 //[RegistryPermissionAttribute(SecurityAction.PermitOnly, Write = @"HKEY_LOCAL_MACHINE\SOFTWARE\DBFConvert")]
 private void ClearReg(Microsoft.Win32.RegistryKey localRegKey, Microsoft.Win32.RegistryKey userRegKey)
 {
     string[] subkeys = localRegKey.OpenSubKey(regPath,true).GetSubKeyNames();
     foreach (string key in subkeys)
     {
         localRegKey.DeleteSubKeyTree(key);
     }
     subkeys = userRegKey.OpenSubKey(regPath,true).GetSubKeyNames();
     foreach (string key in subkeys)
     {
         localRegKey.DeleteSubKeyTree(key);
     }
 }
开发者ID:NEU108,项目名称:DBFConvert,代码行数:15,代码来源:F_RegisterForm.cs

示例3: GetRegString

        public static string GetRegString( Microsoft.Win32.RegistryKey hkey, string vname )
        {
            try
            {
                RegistryKey key = hkey.OpenSubKey( RazorRegPath ) ;
                if ( key == null )
                {
                    key = hkey.CreateSubKey( RazorRegPath );
                    if ( key == null )
                        return null;
                }

                string v = key.GetValue( vname ) as string;

                if ( v == null )
                    return null;
                return v.Trim();
            }
            catch
            {
                return null;
            }
        }
开发者ID:herculesjr,项目名称:razor,代码行数:23,代码来源:Main.cs

示例4: CopyKeyRecursive

                private static void CopyKeyRecursive(Microsoft.Win32.RegistryKey sourceKey, Microsoft.Win32.RegistryKey destKey)
                {
                        foreach (string ValueName in sourceKey.GetValueNames()) {
                                object Val = sourceKey.GetValue(ValueName);
                                destKey.SetValue(ValueName, Val, sourceKey.GetValueKind(ValueName));
                        }

                        foreach (string SubKeyName in sourceKey.GetSubKeyNames()) {
                                using (Microsoft.Win32.RegistryKey sourceSubKey = sourceKey.OpenSubKey(SubKeyName, false))
                                using (Microsoft.Win32.RegistryKey destSubKey = destKey.CreateSubKey(SubKeyName)) {
                                        CopyKeyRecursive(sourceSubKey, destSubKey);
                                }
                        }
                }
开发者ID:solutema,项目名称:ultralight,代码行数:14,代码来源:Program.cs

示例5: RenameSubKey

 public static void RenameSubKey(Microsoft.Win32.RegistryKey parentKey, string subKeyName, string newSubKeyName)
 {
         using (Microsoft.Win32.RegistryKey Src = parentKey.OpenSubKey(subKeyName, false))
         using (Microsoft.Win32.RegistryKey Dest = parentKey.CreateSubKey(newSubKeyName)) {
                 CopyKeyRecursive(Src, Dest);
         }
         parentKey.DeleteSubKeyTree(subKeyName);
 }
开发者ID:solutema,项目名称:ultralight,代码行数:8,代码来源:Program.cs

示例6: FindByDisplayName

	private static string FindByDisplayName(Microsoft.Win32.RegistryKey parentKey, string name)
	{

		string[] nameList = parentKey.GetSubKeyNames();
		for (int i = 0; i < nameList.Length; i++)
		{
			Microsoft.Win32.RegistryKey regKey = parentKey.OpenSubKey(nameList[i]);
			try
			{
				
				if (regKey.GetValue("DisplayName").ToString() == name)
				{
					return regKey.GetValue("InstallLocation").ToString();
				}
				else{
					//Debug.Log(nameList[i] + ", " + regKey.Name + " : " + regKey.GetValue("InstallLocation").ToString());
				}
			}
			catch { 
				//Debug.LogError ("AAA");
			}
		}
		return "";
	}
开发者ID:ozonexo3,项目名称:FAForeverMapEditor,代码行数:24,代码来源:EnvPaths.cs

示例7: VerifyRegistryKeyPermission

        /// <summary>
        /// Verify that a specific user has access rights to a specific Registry Key
        /// </summary>
        /// <param name="userName">Name of the user to check for</param>
        /// <param name="root">Root key for the registry key</param>
        /// <param name="subKey">Registry key to check for</param>
        /// <param name="rights">Expected access rights</param>
        public static void VerifyRegistryKeyPermission(string userName, Microsoft.Win32.RegistryKey root, string subKey, RegistryRights rights)
        {
            RegistryKey registryKey = root.OpenSubKey(subKey);
            RegistrySecurity registrySecurity = registryKey.GetAccessControl();
            AuthorizationRuleCollection accessRules = registrySecurity.GetAccessRules(true, true, typeof(NTAccount));

            foreach (RegistryAccessRule accessRule in accessRules)
            {
                if (userName.ToLowerInvariant().Equals(accessRule.IdentityReference.Value.ToLowerInvariant()))
                {
                    if ((accessRule.RegistryRights & rights) == rights)
                    {
                        return;
                    }
                }
            }

            Assert.True(false, string.Format("User '{0}' do not have the correct permessions to RegistryKey '{1}/{2}'.", userName, root.ToString(), subKey));
        }
开发者ID:bleissem,项目名称:wix3,代码行数:26,代码来源:PermissionsVerifier.cs

示例8: RemoveRegistryKeyPermission

        /// <summary>
        /// Remove Permissions on a Registry key
        /// </summary>
        /// <param name="userName">the user name to remove permissions for</param>
        /// <param name="root">the root hive</param>
        /// <param name="subKey">the key</param>
        public static void RemoveRegistryKeyPermission(string userName, Microsoft.Win32.RegistryKey root, string subKey)
        {
            RegistryKey registryKey = root.OpenSubKey(subKey);
            RegistrySecurity registrySecurity = registryKey.GetAccessControl();
            AuthorizationRuleCollection accessRules = registrySecurity.GetAccessRules(true, true, typeof(NTAccount));

            foreach (RegistryAccessRule accessRule in accessRules)
            {
                if (userName.ToLowerInvariant().Equals(accessRule.IdentityReference.Value.ToLowerInvariant()))
                {
                    registrySecurity.RemoveAccessRule(accessRule);
                }
            }
        }
开发者ID:bleissem,项目名称:wix3,代码行数:20,代码来源:PermissionsVerifier.cs

示例9: Load

        /* ----------------------------------------------------------------- */
        ///
        /// Load
        /// 
        /// <summary>
        /// ユーザ毎の設定情報をレジストリからロードします。
        /// </summary>
        /// 
        /// <remarks>
        /// LastCheckUpdate の項目のみ、保存場所が異なるので別途処理を行って
        /// います。
        /// </remarks>
        /// 
        /* ----------------------------------------------------------------- */
        public bool Load(Microsoft.Win32.RegistryKey root)
        {
            try
            {
                using (var subkey = root.OpenSubKey(_RegRoot, false))
                {
                    using (var child = subkey.OpenSubKey(_RegVersion, false))
                    {
                        var document = new CubePdf.Settings.Document();
                        document.Read(child);
                        Load(document);
                    }

                    var date = subkey.GetValue(_RegLastCheck, string.Empty) as string;
                    if (!string.IsNullOrEmpty(date)) _lastcheck = DateTime.Parse(date as string);
                }
                return true;
            }
            catch (Exception /* err */) { return false; }
        }
开发者ID:cube-soft,项目名称:CubePdf,代码行数:34,代码来源:UserSetting.cs

示例10: GetVsPackages

 public void GetVsPackages(Microsoft.Win32.RegistryKey hiveRoot, Microsoft.Win32.RegistryKey editorKey, string editorExt)
 {
     if ((extension == null) || (System.StringComparer.OrdinalIgnoreCase.Compare(editorExt, extension) == 0))
     {
         string s = editorKey.GetValue("Package") as string;
         if (!System.String.IsNullOrEmpty(s))
         {
             using (Microsoft.Win32.RegistryKey registryKey = hiveRoot.OpenSubKey("Packages\\" + s))
             {
                 if ((registryKey != null) && !editors.ContainsKey(registryKey.Name))
                     editors.Add(registryKey.Name, new VsPackageInfo(registryKey));
             }
         }
     }
 }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:15,代码来源:PDERegistry.cs

示例11: LoadExtensions

        private static void LoadExtensions(Microsoft.Win32.RegistryKey hiveRoot, Helper registry)
        {
            if (hiveRoot == null)
                return;

            using (Microsoft.Win32.RegistryKey registryKey = hiveRoot.OpenSubKey("Editors"))
            {
                if (registryKey == null)
                    return;

                string[] sArr = registryKey.GetSubKeyNames();
                foreach (string keyName in sArr)
                {
                    using (Microsoft.Win32.RegistryKey registrySubKey = registryKey.OpenSubKey(keyName))
                    {
                        if (registrySubKey == null)
                            continue;

                        using (Microsoft.Win32.RegistryKey registryKeyExtensions = registrySubKey.OpenSubKey("Extensions"))
                        {
                            if (registryKeyExtensions == null)
                                continue;
                            string[] sArrExt = registryKeyExtensions.GetValueNames();
                            foreach (string n in sArrExt)
                            {
                                char[] chArr = new char[] { '.', ' ' };
                                string result = n.Trim(chArr).ToUpperInvariant();

                                registry.GetVsPackages(hiveRoot, registrySubKey, result);


                            }
                        }
                    }
                }
            }
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:37,代码来源:PDERegistry.cs

示例12: DoesSoftwareKeyExist

        DoesSoftwareKeyExist(
            string path,
            Microsoft.Win32.RegistryKey registryArea,
            bool query32Bit)
        {
            if (!OSUtilities.IsWindowsHosting)
            {
                return false;
            }

            var exists = true;
            using (var key = registryArea.OpenSubKey(SoftwareKeyPath(path, query32Bit)))
            {
                if (null == key)
                {
                    exists = false;
                }
            }

            return exists;
        }
开发者ID:knocte,项目名称:BuildAMation,代码行数:21,代码来源:Win32RegistryUtilities.cs

示例13: OpenSoftwareKey

        OpenSoftwareKey(
            string path,
            Microsoft.Win32.RegistryKey registryArea,
            bool query32Bit)
        {
            if (!OSUtilities.IsWindowsHosting)
            {
                return null;
            }

            var keyPath = SoftwareKeyPath(path, query32Bit);
            var key = registryArea.OpenSubKey(keyPath);
            if (null == key)
            {
                Log.DebugMessage("Registry key '{0}' on {1} not found", keyPath, registryArea.Name);
            }
            return key;
        }
开发者ID:knocte,项目名称:BuildAMation,代码行数:18,代码来源:Win32RegistryUtilities.cs


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