當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。