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


C# RegistryKey.SetValue方法代码示例

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


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

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

示例2: AddFreddyToRegistry

 private static void AddFreddyToRegistry()
 {
     _key = Registry.CurrentUser.CreateSubKey("SpringIocQuickStartVariableSources");
     _key.SetValue("freddy_name", "Freddy Rumsen");
     _key.SetValue("freddy_age", 44, RegistryValueKind.DWord);
     _key.Flush();
 }
开发者ID:serra,项目名称:spring-net-examples,代码行数:7,代码来源:Program.cs

示例3: checklogintime

        public void checklogintime()
        {
            mainwindow.CurrentStartTime = DateTime.Now.Date;

            rsg = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Sakuya\\" + mainwindow.name);
            rsg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Sakuya\\" + mainwindow.name, true);

            Thread.Sleep(50);

            if (mainwindow.CurrentStartTime == mainwindow.LastStartTime)//如果是今天第N次打开
            {
                mainwindow.LoginTime = (mainwindow.CurrentStartTime - mainwindow.inStartTime).TotalDays;
            }
            else if ((mainwindow.CurrentStartTime - mainwindow.inStartTime).TotalDays == 1)//如果就在第二天
            {
                mainwindow.LoginTime = (mainwindow.CurrentStartTime - mainwindow.inStartTime).TotalDays;
                rsg.SetValue("LastStartTime", Convert.ToString(mainwindow.CurrentStartTime));
            }
            else//不是在第二天
            {
                if ((mainwindow.CurrentStartTime - mainwindow.LastStartTime).TotalDays == 1)//如果是在上一次记录的后面一天
                {
                    mainwindow.LoginTime = (mainwindow.CurrentStartTime - mainwindow.inStartTime).TotalDays;
                    rsg.SetValue("LastStartTime", Convert.ToString(mainwindow.CurrentStartTime));
                }
                else//如果不是连续打开的
                {
                    rsg.SetValue("inStartTime", Convert.ToString(mainwindow.CurrentStartTime));
                    rsg.SetValue("LastStartTime", Convert.ToString(mainwindow.CurrentStartTime));
                    mainwindow.inStartTime = mainwindow.CurrentStartTime;
                }
            }
        }
开发者ID:AldarisX,项目名称:Sakuya-Aki,代码行数:33,代码来源:Statectrl.cs

示例4: AddFreddyToRegistry

 private static void AddFreddyToRegistry()
 {
     _key = Registry.CurrentUser.CreateSubKey(_subkey);
     _key.SetValue("freddy_name", "Freddy Rumsen");
     _key.SetValue("freddy_age", 44, RegistryValueKind.DWord);
     _key.Flush();
 }
开发者ID:serra,项目名称:spring-net-examples,代码行数:7,代码来源:RegistryVariableSourceTests.cs

示例5: CreateRK

 private void CreateRK(RegistryKey rk)
 {
     rk = rk.CreateSubKey(sProtocol);
     rk.SetValue("URL Protocol", "");
     rk = rk.CreateSubKey("Shell");
     rk = rk.CreateSubKey("Open");
     rk = rk.CreateSubKey("Command");
     rk.SetValue(null,sExe);
 }
开发者ID:dingxinbei,项目名称:LogWin,代码行数:9,代码来源:Register.cs

示例6: SetUp

        public void SetUp()
        {
            key = Registry.CurrentUser.CreateSubKey("RegistryVariableSourceTests");
            key.SetValue("name", "Aleks Seovic");
            key.SetValue("computer_name", "%COMPUTERNAME% is the name of my computer", RegistryValueKind.ExpandString);
            key.SetValue("age", 32, RegistryValueKind.DWord);
			key.SetValue("family", new string[] {"Marija", "Ana", "Nadja"});
            key.SetValue("bday", new byte[] {24, 8, 74});
			key.Flush();
        }
开发者ID:Binodesk,项目名称:spring-net,代码行数:10,代码来源:RegistryVariableSourceTests.cs

示例7: Save

        public void Save(RegistryKey regkey)
        {
            Trim();
            if (history.Count == 0)
                return;

            regkey.SetValue(key, history[0]);
            for (int i = 1; i < history.Count; i++)
                regkey.SetValue(key + i.ToString(CultureInfo.InvariantCulture), history[i]);
        }
开发者ID:pantarhei,项目名称:e-find-in-files,代码行数:10,代码来源:ComboBoxHistory.cs

示例8: button1_Click

 private void button1_Click(object sender, EventArgs e)
 {
     Host = textHost.Text;
     Login = textLogin.Text;
     Password = textPass.Text;
     regKey = Registry.CurrentUser;
     regKey = regKey.CreateSubKey("Software\\TickNet\\DBServer");
     regKey.SetValue("DB_Server",textHost.Text);
     regKey.SetValue("DB_Login",textLogin.Text);
     regKey.SetValue("DB_Pass",textPass.Text);
     this.DialogResult = DialogResult.OK;
 }
开发者ID:YourTradingSystems,项目名称:TickNet_Test,代码行数:12,代码来源:ConnectionDlg.cs

示例9: IEHeaderFooterSettings

		/// <summary>
		/// Page setup with the specifed header and footer.
		/// </summary>
		/// <param name="header"></param>
		/// <param name="footer"></param>
		public IEHeaderFooterSettings(string header, string footer)
		{
			_iePageSetupKey = Registry.CurrentUser.OpenSubKey(_iePageSetupKeyPath, true);
			_header = header;
			_footer = footer;

			if (_iePageSetupKey != null)
			{
				_oldHeader = (string)_iePageSetupKey.GetValue("header");
				_oldFooter = (string)_iePageSetupKey.GetValue("footer");

				_iePageSetupKey.SetValue("header", _header);
				_iePageSetupKey.SetValue("footer", _footer);
			}
		}
开发者ID:nhannd,项目名称:Xian,代码行数:20,代码来源:IEHeaderFooterSettings.cs

示例10: CheckValidOrCreateRegValue

		/// <summary>
		/// Checks if a stringValue is available. If it is not, it creates it
		/// </summary>
		/// <param name="subKey"></param>
		/// <param name="stringValue"></param>
		/// <param name="defaultStringValue"></param>
		/// <returns></returns>
		private static bool CheckValidOrCreateRegValue(RegistryKey subKey, string propertyName, string defaultStringValue)
		{
			try
			{								
				if(subKey.GetValue(propertyName) == null)
				{	
					if(defaultStringValue == null)
					{
						return true;
					}
					//create the stringvlaue
					subKey.SetValue(propertyName, defaultStringValue);
					return true;
				}
				else
				{
					return true;
				}								
			}
			catch(Exception ex)
			{
				log.Error(ex);
				return false;
			}
		}
开发者ID:BrianGoff,项目名称:BITS,代码行数:32,代码来源:RegistryUtils.cs

示例11: SetRegistryData

 public static void SetRegistryData(RegistryKey key, string path, string item, string value)
 {
     string[] keys = path.Split(new char[] {'/'},StringSplitOptions.RemoveEmptyEntries);
     try
     {
         if (keys.Count() == 0)
         {
             key.SetValue(item, value);
             key.Close();
         }
         else
         {
             string[] subKeys = key.GetSubKeyNames();
             if (subKeys.Where(s => s.ToLowerInvariant() == keys[0].ToLowerInvariant()).FirstOrDefault() != null)
             {
                 //Open subkey
                 RegistryKey sub = key.OpenSubKey(keys[0], (keys.Count() == 1));
                 if (keys.Length > 1)
                     SetRegistryData(sub, path.Substring(keys[0].Length + 1), item, value);
                 else
                     SetRegistryData(sub, string.Empty, item, value);
             }
             else
             {
                 SetRegistryData(key.CreateSubKey(keys[0]), path.Substring(keys[0].Length + 1), item, value);
             }
         }
     }
     catch { }
 }
开发者ID:Kayomani,项目名称:FAP,代码行数:30,代码来源:RegistryHelper.cs

示例12: Configuration

        public Configuration()
        {
            OperatingSystem os = Environment.OSVersion;
            Console.WriteLine ("OS platform: " + os.Platform);
            this.platform = os.Platform.ToString ();

            if (this.platform.StartsWith ("Win")) {

                RegistryKey CurrentUserKey = Microsoft.Win32.Registry.CurrentUser;

                string OurAppKeyStr = @"SOFTWARE\moNotationalVelocity";
                OurAppRootKey = CurrentUserKey.CreateSubKey (OurAppKeyStr);
                ConfigKey = OurAppRootKey.CreateSubKey ("config");

                this.notesDirPath = ConfigKey.GetValue ("notesDirPath") as string;
                if (this.notesDirPath == null) {
                    Console.WriteLine ("No configuration");
                    this.notesDirPath = defaulNotesDirtPath;
                    ConfigKey.SetValue ("notesDirPath", this.notesDirPath, RegistryValueKind.String);
                }

                ConfigKey.Flush ();

            } else {

                this.notesDirPath = defaulNotesDirtPath;
            }
        }
开发者ID:mzehrer,项目名称:monovel,代码行数:28,代码来源:Configuration.cs

示例13: registerProgram

 public bool registerProgram(string appName, string pathToExe)
 {
     try
     {
         if (!isProgramRegistered(appName))
         {
             startupKey = Registry.CurrentUser.OpenSubKey(runKey);
             if (startupKey.GetValue(appName) == null)
             {
                 startupKey.Close();
                 startupKey = Registry.CurrentUser.OpenSubKey(runKey, true);
                 startupKey.SetValue(appName, pathToExe);
             }
         }
     }
     catch (Exception)
     {
         return false;
     }
     finally
     {
         startupKey.Close();
     }
     return true;
 }
开发者ID:RisingFog,项目名称:vibranceGUI,代码行数:25,代码来源:RegistryController.cs

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

示例15: IISFix

        /// <summary>
        /// This fixes my mistake for naming IIS process "wp3.exe" and not "w3wp.exe" like it should be.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="descriptorIndex"></param>
        internal static void IISFix(RegistryKey key, int descriptorIndex)
        {
            try
            {
                // get the name.

                var name = key.GetStringValue(ATASettings.Keys.AttachDescriptorName, descriptorIndex);
                var processGroup = key.GetStringValue(ATASettings.Keys.AttachDescriptorProcessNames, descriptorIndex);

                var allProcesses = ((string) key.GetValue(processGroup)).Split(new[] {ATAConstants.ProcessNamesSeparator[0]}, StringSplitOptions.RemoveEmptyEntries);

                const string badProcessName = "wp3.exe";
                // does it have the fouled-up process name?
                var hasWp3 = allProcesses.Any(s => string.Compare(s, badProcessName, StringComparison.OrdinalIgnoreCase) == 0);
                // if it is iis, and it has the wrong process, fix that shit.
                if (string.Compare(name, "iis", StringComparison.OrdinalIgnoreCase) != 0 || !hasWp3)
                {
                    return;
                }
                var newList = allProcesses.Where(s => string.Compare(s, badProcessName, StringComparison.OrdinalIgnoreCase) != 0).Concat(new[] {ATAConstants.ProcessNames.IISWorkerProcessName});
                key.SetValue(processGroup, string.Join(ATAConstants.ProcessNamesSeparator, newList));
            }
            catch (Exception)
            {
                // if we dont have access to write, there is a problem.
            }
        }
开发者ID:arcdev,项目名称:AttachToAny,代码行数:32,代码来源:Migrator.cs


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