Exemplo n.º 1
0
 private static bool RegWrite(string KeyName, string Value)
 {
     return(UseReg((SubKey) =>
     {
         SubKey.SetValue(KeyName, Value);
         return true;
     }));
 }
Exemplo n.º 2
0
        /// <summary>
        /// 修改注册表
        /// </summary>
        /// <param name="key">注册表键</param>
        /// <param name="name">项</param>
        /// <param name="value">值</param>
        private void UpdatePortInRegedit(string key, string name, string value)
        {
            RegistryKey RootKey;
            RegistryKey SubKey;

            RootKey = Registry.LocalMachine;
            try
            {
                SubKey = RootKey.OpenSubKey(key, true);
                if (SubKey != null)
                {
                    SubKey.SetValue(name, value);
                }
                SubKey.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n\r" + ex.StackTrace);
            }
        }