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


C# RegistryKey.DeleteValue方法代码示例

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


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

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

示例2: SystemInformation

        internal SystemInformation(RegistryKey key)
        {
            bool loaded = false;

            LastStartupDateTime = DateTime.Now;

            try
            {
                if (key.GetValue(KeyInstallation) != null)
                {
                    InstallationDateTime = DateTime.ParseExact(
                        (string)key.GetValue(KeyInstallation), "O",
                        CultureInfo.InvariantCulture
                    );

                    string lastReportDate = (string)key.GetValue(KeyLastReport);

                    if (lastReportDate != null)
                    {
                        LastReportDateTime = DateTime.ParseExact(
                            lastReportDate, "O", CultureInfo.InvariantCulture
                        );
                    }

#if CACHE_SYSTEM_INFORMATION
                    OperatingSystem = (string)key.GetValue(KeyOperatingSystem);
                    OperationSystemVersion = (string)key.GetValue(KeyOperationSystemVersion);
                    Cpu = (string)key.GetValue(KeyCpu);
                    CpuInformation = (string)key.GetValue(KeyCpuInformation);
#endif

                    loaded = true;
                }
            }
            catch
            {
                // If we were unable to load the settings, initialize new settings.
            }

            if (!loaded)
            {
                Detect();

                key.SetValue(KeyInstallation, InstallationDateTime.ToString("O"));

                if (key.GetValue(KeyLastReport) != null)
                    key.DeleteValue(KeyLastReport);

#if CACHE_SYSTEM_INFORMATION
                key.SetValue(KeyOperatingSystem, OperatingSystem);
                key.SetValue(KeyOperationSystemVersion, OperationSystemVersion);
                key.SetValue(KeyCpu, Cpu);
                key.SetValue(KeyCpuInformation, CpuInformation);
#endif
            }

#if !CACHE_SYSTEM_INFORMATION
            DetectSystemInformation();
#endif
        }
开发者ID:pvginkel,项目名称:CrashReporter.NET,代码行数:60,代码来源:SystemInformation.cs

示例3: RenameFontName

        public static void RenameFontName(RegistryKey key, string original, string target, string value)
        {
            // TODO: Use transection.

            key.SetValue(target, value);
            key.DeleteValue(original);
        }
开发者ID:EFanZh,项目名称:EFanZh,代码行数:7,代码来源:Utility.cs

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

示例5: SafeDeleteRegistryValue

 public static void SafeDeleteRegistryValue(RegistryKey regKey, String keyName)
 {
     // Can't extend Microsoft.Win32.RegistryKey since its sealed, hence has to put this in Utils.cs
     try {
         regKey.DeleteValue(keyName);
     } catch (ArgumentException) {
     }
 }
开发者ID:rockycoder,项目名称:windows-tweaker,代码行数:8,代码来源:Utils.cs

示例6: CreateComponentValue

        internal void CreateComponentValue(RegistryKey componentKey, string name, object value, RegistryValueKind kind)
        {
            if (null == componentKey)
                throw new ArgumentNullException("Unable to find specified registry key.");

            if (componentKey.GetValue(name, null) != null && componentKey.GetValueKind(name) != kind)
                componentKey.DeleteValue(name, false);

            componentKey.SetValue(name, value, kind);
        }
开发者ID:netoffice,项目名称:NetOffice,代码行数:10,代码来源:Registry.cs

示例7: SetCheckedStateFromString

 /// <summary>
 /// Updates the checked state of the <paramref name="chk"/> if the <paramref name="valueName"/>
 /// evaluates to true (i.e., '1' (REG_SZ)) for the passed in <paramref name="registryKey"/>. 
 /// However, if <paramref name="inverse"/> is to true, it updates the checkbox state in reverse manner, i.e., 
 /// if the <paramref name="valueName"/> evaluates to true (i.e., 1), checkbox is set to unchecked.
 /// </summary>
 /// <param name="chk"></param>
 /// <param name="registryKey"></param>
 /// <param name="valueName"></param>
 /// <param name="inverse"></param>
 internal static void SetCheckedStateFromString(this CheckBox chk, RegistryKey registryKey,
     string valueName, bool inverse = false)
 {
     try {
         string val = (string) registryKey.GetValue(valueName);
         chk.IsChecked = inverse ? Utils.ReversedStringToBool(val) : Utils.StringToBool(val);
     } catch (InvalidCastException) {
         registryKey.DeleteValue(valueName, false);
         chk.IsChecked = false;
     }
 }
开发者ID:pankajbhandari08,项目名称:windows-tweaker,代码行数:21,代码来源:UIRegistryHandler.cs

示例8: ConditionalSetValue

 private void ConditionalSetValue( RegistryKey key, String valueName, String value )
 {
     if (String.IsNullOrEmpty( value ))
     {
         key.DeleteValue( valueName, false );
     }
     else
     {
         key.SetValue( valueName, value );
     }
 }
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:11,代码来源:RegisterEmulator.cs

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

示例10: SetCheckedState

 /// <summary>
 /// Updates the checked state of the <paramref name="chk"/> if the <paramref name="valueName"/>
 /// evaluates to true (i.e., 1 (REG_DWORD or REG_QWORD)) for the passed in <paramref name="registryKey"/>. 
 /// However, if <paramref name="inverse"/> is to true, it updates the checkbox state in reverse manner, i.e., 
 /// if the <paramref name="valueName"/> evaluates to true (i.e., 1), checkbox is set to unchecked.
 /// </summary>
 /// <param name="chk"></param>
 /// <param name="registryKey"></param>
 /// <param name="valueName"></param>
 /// <param name="inverse"></param>
 /// <param name="nullAsTrue"></param>
 internal static void SetCheckedState(this CheckBox chk, RegistryKey registryKey, 
     string valueName, bool inverse=false, bool nullAsTrue=false)
 {
     try {
         int? val = (int?) registryKey.GetValue(valueName);
         if (inverse && !val.HasValue && nullAsTrue) {
             chk.IsChecked = true;
             return;
         }
         chk.IsChecked = inverse ? Utils.ReversedIntToBool(val) : Utils.IntToBool(val);
     } catch (InvalidCastException) {
         registryKey.DeleteValue(valueName, false);
         chk.IsChecked = false;
     }
 }
开发者ID:pankajbhandari08,项目名称:windows-tweaker,代码行数:26,代码来源:UIRegistryHandler.cs

示例11: unregisterProgram

 public bool unregisterProgram(string appName)
 {
     try
     {
         startupKey = Registry.CurrentUser.OpenSubKey(runKey, true);
         startupKey.DeleteValue(appName, true);
     }
     catch (Exception)
     {
         return false;
     }
     finally
     {
         startupKey.Close();
     }
     return true;
 }
开发者ID:RisingFog,项目名称:vibranceGUI,代码行数:17,代码来源:RegistryController.cs

示例12: deleteValue

 private static bool deleteValue(int Section, string Location, string Value)
 {
     key = getKeySection(Section);
     try
     {
         key = key.OpenSubKey(Location,true);
         key.DeleteValue(Value, false);
     }
     catch
     {
         return false;
     }
     finally
     {
         key.Close();
     }
     return true;
 }
开发者ID:sdasun,项目名称:KeyTouch,代码行数:18,代码来源:Startup.cs

示例13: Delete

        public static RegistryError Delete(RegistryKey regKey, string location, string value)
        {
            RegistryError rerr = RegistryError.None;

            try
            {
                regKey = regKey.OpenSubKey(location, true);
                regKey.DeleteValue(value, false);
            }
            catch (Exception e)
            {
                rerr = RegistryError.Error;
                Tracer.Error(e);
            }
            finally
            {
                regKey.Close();
            }

            return rerr;
        }
开发者ID:jeffboulanger,项目名称:connectuo,代码行数:21,代码来源:RegistryHelper.cs

示例14: TestInitialize

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

            Random rand = new Random(10);
            Byte[] byteArr = new Byte[rand.Next(0, 100)];
            rand.NextBytes(byteArr);

            _objArr = new Object[6];
            _objArr[0] = (Int32)(rand.Next(Int32.MinValue, Int32.MaxValue));
            _objArr[1] = (Int64)(rand.NextDouble() * Int64.MaxValue);
            _objArr[2] = (String)"Hello World";
            _objArr[3] = (String)"Hello %path5% World";
            _objArr[4] = new String[] { "Hello World", "Hello %path% World" };
            _objArr[5] = (Byte[])(byteArr);
        }
开发者ID:gitter-badger,项目名称:corefx,代码行数:23,代码来源:RegistryKey_GetValueKind_str.cs

示例15: AutoStartUpC

 private void AutoStartUpC(object sender, EventArgs e)
 {
     rsg = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\");
     rsg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\", true);
     rsg.DeleteValue(mainwindow.programname);
     mainwindow.displaytips("已经取消了哦", 2000);
     startup.Checked = false;
     startupc.Checked = true;
 }
开发者ID:AldarisX,项目名称:Sakuya-Aki,代码行数:9,代码来源:BackGroundShell.cs


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