日期:2014-05-18 浏览次数:20971 次
using System;
using Microsoft.Win32;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace IE进程管理
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnChangeIEProcessNum_Click(object sender, EventArgs e)
{
RegistryKey key = Registry.CurrentUser;
RegistryKey ieProcessNum = key.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main", true);
string[] valueName;
valueName = ieProcessNum.GetValueNames();
foreach (string s in valueName)
{
if (s == "TabProcGrowth")
{
MessageBox.Show("键值存在", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (s != "TabProcGrowth")//添加这部分后,程序就一直提示键值不存在,直到最后才输出键值存在。
{
MessageBox.Show("键值不存在,要创建吗?", "提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
return;
}
}
}
}
}
bool bFound = false;
foreach (string s in valueName)
{
if (s == "TabProcGrowth")
{
bFound = true;
break;
}
}
if (bFound)
{
// 有
}
else
{
// 木有
}