- RegistryKey masterKey = Registry.LocalMachine.CreateSubKey
- ("SOFTWARE\\\\Test\\\\Preferences");
- if (masterKey == null)
- {
- Console.WriteLine ("Null Masterkey!");
- }
- else
- {
- try
- {
- masterKey.SetValue ("MyKey", "MyValue");
- }
- catch (Exception ex)
- {
- Console.WriteLine (ex.Message);
- }
- finally
- {
- masterKey.Close();
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/030620133724.html
来源: http://www.codesnippet.cn/detail/030620133724.html