- 分享
- 0
- 人气
- 7
- 主题
- 13
- 帖子
- 1837
- UID
- 76124
- 积分
- 2113
- 阅读权限
- 20
- 注册时间
- 2007-5-6
- 最后登录
- 2018-4-22
- 在线时间
- 1487 小时
|
怕忘记 这边记录
• HKEY_CLASSES_ROOT
- Administrator Group - Full Control, Read
- Power User Group - Read, Special Permissions
- User Group - Read
- System Account - Full Control, Read
• HKEY_CURRENT_CONFIG
- Administrator Group- Full Control, Read
- Power User Group - Read
- User Group - Read
- System Account - Full Control, Read
• HKEY_CURRENT_USER
- Administrator Group - Full Control, Read
- Current User - Full Control, Read
- System Account - Full Control, Read
• HKEY_LOCAL_MACHINE
- Administrator Group - Full Control, Read
- Everyone Group - Read
- System Account - Full Control, Read
• HKEY_USERS
- Administrator Group - Full Control, Read
- Everyone Group - Read
- System Account - Full Control, Read
引用
using Microsoft.Win32
写入和查寻
-
- // Creates a subkey named myApplication under HKEY_CURRENT_USER.
- RegistryKey regKey = Registry.CurrentUser.CreateSubKey("myApplication");
- // There are two methods, which can be used to add subkeys and values
- // to the registry. These are:
- //
- // RegistryKey.SetValue(string name, object value)
- // RegistryKey.SetValue(string name, object value, RegistryValueKind valueKind)
- // First Method:
- // Creates a subkey under the new registry key myApplication and
- // writes a value to the new subkey.
- regKey.SetValue("myValue", "This is a test");
- // Multiple subKeys can be created at a time
- // as shown in the example code below:
- //
- // regKey.SetValue("myValue1", "Test Value 1");
- // regKey.SetValue("myValue2", "Test Value 2");
- // Second Method:
- // Creates subkeys under the registry key myApplication and
- // writes common value types.
- //
- // regKey.SetValue("DWordValue", 10, RegistryValueKind.DWord);
- // regKey.SetValue("MultipleStringValue", new string[] { "One", "Two", "Three" }, RegistryValueKind.MultiString);
- // regKey.SetValue("BinaryValue", new byte[] { 8, 16, 32, 64, 128, 256 }, RegistryValueKind.Binary);
- // regKey.SetValue("StringValue", "The directory path is %PATH%", RegistryValueKind.String);
- // regKey.SetValue("ExpandedStringValue", "The directory path is %PATH%", RegistryValueKind.ExpandString);
复制代码
拿出来
-
- // Opens the subkey called myApplication.
- RegistryKey regKey = Registry.CurrentUser.OpenSubKey("myApplication");
- // Checks to see if the value of the subkey is null.
- if (regKey == null)
- {
- // If the subkey does not exist than a MessageBox will be displayed.
- MessageBox.Show("The registry key that you are trying to "
- + Environment.NewLine + "read does not exist.",
- "Registry Key Does Not Exist", MessageBoxButtons.OK,
- MessageBoxIcon.Information);
- }
- else
- {
- // Reads the subkey value for myValue from the registy
- // key HKEY_CURRENT_USER/myApplication.
- MessageBox.Show(regKey.GetValue("myValue").ToString(), "Registry SubKey Value",
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
复制代码
delete
- // Opens the subkey called myApplication
- RegistryKey regKey = Registry.CurrentUser.OpenSubKey("myApplication", true);
-
- // Checks to see if the value of the subkey is null
- if (regKey == null)
- {
- // If the subkey does not exist than a MessageBox will be displayed.
- MessageBox.Show("The registry key that you are trying to "
- + Environment.NewLine + "delete does not exist.",
- "Registry Key Does Not Exist", MessageBoxButtons.OK,
- MessageBoxIcon.Information);
- }
- else
- {
- // Verifies that the registry key is not already deleted.
- if (!Convert.ToBoolean(Registry.CurrentUser.OpenSubKey("myApplication") == null))
- {
- // Deletes the subkey and any child subkeys under
- // the registry key HKEY_CURRENT_USER/myApplication.
- Registry.CurrentUser.DeleteSubKeyTree("myApplication");
- // Deletes a subkey and it's value under the registry
- // key myApplication.
- //regKey.DeleteValue("myValue");
- // If the deletion was successful than a MessageBox
- // will be displayed.
- MessageBox.Show("The registry key was deleted successfully.",
- "Registry Key Deleted", MessageBoxButtons.OK,
- MessageBoxIcon.Information);
- }
- else
- {
- // If the subkey does not exist than a MessageBox will be displayed.
- MessageBox.Show("The registry key that you are trying to "
- + Environment.NewLine + "delete does not exist.",
- "Registry Key Does Not Exist", MessageBoxButtons.OK,
- MessageBoxIcon.Information);
- }
- }
复制代码
转载
http://vbcity.com/forums/faq.asp?fid=31&cat=Registry |
|