利用C#编写修改注册表的程序代码
//主要方法,用来修改注册表的
private bool SetValue(string temp)
{
try
{
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\{B83FC273-3522-4CC6-92EC-75CC86678DA4}",true);
object str = key.GetValue("Compatibility Flags");
if(str.ToString() != String.Empty)
key.SetValue("Compatibility Flags",temp);//修改键值
key.Flush();
key.Close();
return true;
}
catch
{
return false;
}
}
//按钮触发事件,更换3721在注册表的信息
private void kill_Click(object sender, System.EventArgs e)
{
if(SetValue("1024"))
{
lblMsg.Text = ("3721已被清除");
}
else
{
lblMsg.Text = ("信息修改失败");
}
}
//按钮触发事件,更换3721在注册表的信息
private void release_Click(object sender, System.EventArgs e)
{
if(SetValue("0"))
{
lblMsg.Text = ("3721已被重新注入Windows注册表信息中:)");
}
else
{
lblMsg.Text = ("信息修改失败");
}
}
private bool SetValue(string temp)
{
try
{
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\{B83FC273-3522-4CC6-92EC-75CC86678DA4}",true);
object str = key.GetValue("Compatibility Flags");
if(str.ToString() != String.Empty)
key.SetValue("Compatibility Flags",temp);//修改键值
key.Flush();
key.Close();
return true;
}
catch
{
return false;
}
}
//按钮触发事件,更换3721在注册表的信息
private void kill_Click(object sender, System.EventArgs e)
{
if(SetValue("1024"))
{
lblMsg.Text = ("3721已被清除");
}
else
{
lblMsg.Text = ("信息修改失败");
}
}
//按钮触发事件,更换3721在注册表的信息
private void release_Click(object sender, System.EventArgs e)
{
if(SetValue("0"))
{
lblMsg.Text = ("3721已被重新注入Windows注册表信息中:)");
}
else
{
lblMsg.Text = ("信息修改失败");
}
}