C# 操作windows注册表
2018-07-20 来源:open-open
此代码演示了如何读取和写入注册表
读取注册表private string GetRegistShellData(string RegistName) { try { string registData, SubregistData; RegistryKey hkml = Registry.LocalMachine; RegistryKey software = hkml.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true); registData = software.GetValue(RegistName).ToString(); SubregistData = registData.Substring(0, 2); return SubregistData; } catch (Exception excp) { MessageBox.Show("GetRegistShellData错误" + excp.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return ""; } /// <summary>
写入注册表
private void RenameRegistData() { try { string registData1; RegistryKey hkml = Registry.LocalMachine; RegistryKey software2 = hkml.OpenSubKey(@"SOFTWARE\"+ Shadowin + @"\SysToolSign", true); registData1 = software2.GetValue("Sign").ToString(); software2.SetValue("Sign", "1"); registData1 = software2.GetValue("Sign").ToString(); } catch (Exception excp) { MessageBox.Show("RenameRegistData错误" + excp.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return ; }
标签: 代码
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
最新资讯
热门推荐