RegistryKey reg = Registry.LocalMachine;
using (RegistryKey run = reg.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true))
{
var key = "ch2.Spider.SiteManager.exe";
var value = run.GetValue(key);
if (value == null)
{
try
{
Int32 tempInt = 0;
unchecked
{
tempInt = (Int32)0x2AF9;
}
run.SetValue(key, tempInt, RegistryValueKind.DWord);
MessageBox.Show(" 当前应用程序已成功写入注册表!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show(value.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}