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


C# RegistryKey.DeleteSubKeyTree方法代码示例

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


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

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

示例2: TestInitialize

 public void TestInitialize()
 {
     _rk = Registry.CurrentUser.OpenSubKey("Software", true);
     if (_rk.OpenSubKey(_testKeyName) != null)
         _rk.DeleteSubKeyTree(_testKeyName);
     if (_rk.OpenSubKey(_testVolatileKeyName) != null)
         _rk.DeleteSubKeyTree(_testVolatileKeyName);
     if (_rk.OpenSubKey(_testNonVolatileKeyName) != null)
         _rk.DeleteSubKeyTree(_testNonVolatileKeyName);
     if (_rk.OpenSubKey(_testRegularKey) != null)
         _rk.DeleteSubKeyTree(_testRegularKey);
 }
开发者ID:gitter-badger,项目名称:corefx,代码行数:12,代码来源:RegistryKeyTypes.cs

示例3: TestInitialize

 public void TestInitialize()
 {
     var counter = Interlocked.Increment(ref s_keyCount);
     _madeUpKey = _madeUpKey + counter.ToString();
     _rk = Registry.CurrentUser.OpenSubKey("Software", true);
     if (_rk.OpenSubKey(_madeUpKey) != null)
         _rk.DeleteSubKeyTree(_madeUpKey);
     if (_rk.OpenSubKey(_subKeyExists) != null)
         _rk.DeleteSubKeyTree(_subKeyExists);
     if (_rk.OpenSubKey(_subKeyExists2) != null)
         _rk.DeleteSubKeyTree(_subKeyExists2);
 }
开发者ID:gitter-badger,项目名称:corefx,代码行数:12,代码来源:RegistryKey_DeleteSubKeyTree.cs

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

示例5: TestInitialize

        public void TestInitialize()
        {
            var counter = Interlocked.Increment(ref s_keyCount);
            _testKeyName += counter.ToString();
            _testKeyName2 += counter.ToString();
            rk1 = Microsoft.Win32.Registry.CurrentUser;
            if (rk1.OpenSubKey(_testKeyName2) != null)
                rk1.DeleteSubKeyTree(_testKeyName2);
            if (rk1.GetValue(_testKeyName2) != null)
                rk1.DeleteValue(_testKeyName2, false);

            if (rk1.GetValue(_testKeyName) != null)
                rk1.DeleteValue(_testKeyName);
            if (rk1.OpenSubKey(_testKeyName) != null)
                rk1.DeleteSubKeyTree(_testKeyName);
        }
开发者ID:gitter-badger,项目名称:corefx,代码行数:16,代码来源:RegistryKey_DeleteValue_Str_Bln.cs

示例6: Test04

        public void Test04()
        {
            // [] Give subkey a value and then delete tree

            _rk1 = Microsoft.Win32.Registry.CurrentUser;
            _rk1.CreateSubKey(_testKeyName);
            if (_rk1.OpenSubKey(_testKeyName) == null)
            {
                Assert.False(true, "Error Could not get subkey");
            }
            _rk1.DeleteSubKeyTree(_testKeyName);
            if (_rk1.OpenSubKey(_testKeyName) != null)
            {
                Assert.False(true, "Error SubKey still there");
            }

            // CreateSubKey should just open a SubKeyIfIt already exists
            _rk2 = _rk1.CreateSubKey(_testKeyName);
            _rk2.CreateSubKey("BLAH");
            
            if (_rk1.OpenSubKey(_testKeyName).OpenSubKey("BLAH") == null)
            {
                Assert.False(true, "Error Expected get not returned");
            }
            _rk2.DeleteSubKey("BLAH");
            if (_rk2.OpenSubKey("BLAH") != null)
            {
                Assert.False(true, "Error SubKey was not deleted");
            }
        }
开发者ID:gitter-badger,项目名称:corefx,代码行数:30,代码来源:RegistryKey_DeleteSubKeyTree_str.cs

示例7: TestInitialize

        public void TestInitialize()
        {
            var counter = Interlocked.Increment(ref s_keyCount);
            _testKey += counter.ToString();
            _rk1 = Microsoft.Win32.Registry.CurrentUser;
            if (_rk1.OpenSubKey(_testKey) != null)
                _rk1.DeleteSubKeyTree(_testKey);
            if (_rk1.GetValue(_testKey) != null)
                _rk1.DeleteValue(_testKey);

            //created the test key. if that failed it will cause many of the test scenarios below fail.
            try
            {
                _rk1 = Microsoft.Win32.Registry.CurrentUser;
                _rk2 = _rk1.CreateSubKey(_testKey);
                if (_rk2 == null)
                {
                    Assert.False(true, "ERROR: Could not create test subkey, this will fail a couple of scenarios below.");
                }
                else
                    _keyString = _rk2.ToString();
            }
            catch (Exception e)
            {
                Assert.False(true, "ERROR: unexpected exception, " + e.ToString());
            }
        }
开发者ID:gitter-badger,项目名称:corefx,代码行数:27,代码来源:Registry_Getvalue_str_str_obj.cs

示例8: TestInitialize

 public void TestInitialize()
 {
     var counter = Interlocked.Increment(ref s_keyCount);
     _testKeyName = _testKeyName + counter.ToString();
     _rk1 = Microsoft.Win32.Registry.CurrentUser;
     if (_rk1.OpenSubKey(_testKeyName) != null)
         _rk1.DeleteSubKeyTree(_testKeyName);
 }
开发者ID:gitter-badger,项目名称:corefx,代码行数:8,代码来源:RegistryKey_CreateSubKey_str.cs

示例9: Test01

        public void Test01()
        {
            // [] Passing in null should throw ArgumentNullException

            _rk1 = Microsoft.Win32.Registry.CurrentUser;
            Action a = () => { _rk1.DeleteSubKeyTree(null); };
            Assert.Throws<ArgumentNullException>(() => { a(); });
        }
开发者ID:gitter-badger,项目名称:corefx,代码行数:8,代码来源:RegistryKey_DeleteSubKeyTree_str.cs

示例10: DeleteKey

 private static bool DeleteKey(RegistryKey parent, string path)
 {
     if (KeyExists(parent, path))
     {
         parent.DeleteSubKeyTree(path);
         return true;
     }
     return false;
 }
开发者ID:ChadSki,项目名称:MetroIdeTemplate,代码行数:9,代码来源:FileDefaults.cs

示例11: TestInitialize

 public void TestInitialize()
 {
     var counter = Interlocked.Increment(ref s_keyCount);
     _testKey += counter.ToString();
     _rk1 = Microsoft.Win32.Registry.CurrentUser;
     if (_rk1.OpenSubKey(_testKey) != null)
         _rk1.DeleteSubKeyTree(_testKey);
     if (_rk1.GetValue(_testKey) != null)
         _rk1.DeleteValue(_testKey);
     _rk2 = _rk1.CreateSubKey(_testKey);
     _keyString = _rk2.ToString();
 }
开发者ID:gitter-badger,项目名称:corefx,代码行数:12,代码来源:Registry_SetValue_str_str_obj_valuekind.cs

示例12: 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)
        {
          try
          {
            CopyKey(parentKey, subKeyName, newSubKeyName);
            parentKey.DeleteSubKeyTree(subKeyName);
            return true;
          }
          catch (Exception)
          {
            return false;
          }            
        }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:24,代码来源:RegistryUtilities.cs

示例13: SetRegistryKeyFromBool

 /// <summary>
 /// Sets the value of <paramref name="keyName"/> in <paramref name="registryKey"/> to 1 if
 /// <paramref name="val"/> is equal to true, otherwise sets it to 0.
 /// </summary>
 /// <param name="val"></param>
 /// <param name="registryKey"></param>
 /// <param name="keyName"></param>
 public static void SetRegistryKeyFromBool(bool? val, RegistryKey registryKey, String keyName)
 {
     RegistryKey newKey = registryKey.OpenSubKey(keyName, true);
     if (val == true && newKey == null) {
         registryKey.CreateSubKey(keyName);
     } else {
         if (newKey != null) {
             registryKey.DeleteSubKeyTree(keyName);
         }
     }
     if (newKey != null) {
         newKey.Close();
     }
 }
开发者ID:rockycoder,项目名称:windows-tweaker,代码行数:21,代码来源:UIRegistryHandler.cs

示例14: TestInitialize

        public void TestInitialize()
        {
            var counter = Interlocked.Increment(ref s_keyCount);
            _testKeyName = "REG_TEST_12" + counter.ToString();
            _testValueName = "TestValue";
            _testStringName = "TestString" + counter.ToString();
            _testString = "Hello World!†þ";
            _testValue = 11;

            _rk1 = Microsoft.Win32.Registry.CurrentUser;
            if (_rk1.OpenSubKey(_testKeyName) != null)
                _rk1.DeleteSubKeyTree(_testKeyName);
            _rk2 = _rk1.CreateSubKey(_testKeyName);
            _rk2.Dispose();
        }
开发者ID:gitter-badger,项目名称:corefx,代码行数:15,代码来源:RegistryKey_OpenSubKey_str_rkpc.cs

示例15: Test03

        public void Test03()
        {
            // [] Creating new SubKey and deleting it

            _rk1 = Microsoft.Win32.Registry.CurrentUser;
            _rk1.CreateSubKey(_testKeyName);
            if (_rk1.OpenSubKey(_testKeyName) == null)
            {
                Assert.False(true, "Error SubKey does not exist.");
            }

            _rk1.DeleteSubKeyTree(_testKeyName);
            if (_rk1.OpenSubKey(_testKeyName) != null)
            {
                Assert.False(true, "Error SubKey not removed properly");
            }
        }
开发者ID:gitter-badger,项目名称:corefx,代码行数:17,代码来源:RegistryKey_DeleteSubKeyTree_str.cs


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