using Microsoft.Win32; //注册表需要引用此命名空间
1
RegistryKey key
=
Registry.CurrentUser.OpenSubKey(
@"
Software\Microsoft\Windows\CurrentVersion\Run
"
,
true
);
2
3
if
(CBAutoRun.Checked)
4
{
5
key.SetValue("EventAgent", Application.ExecutablePath);
6
}
7
else
8
{
9
key.SetValue("EventAgent", "");
10
}
CheckBox选中写注册表。否清空EventAgent键值

2

3

4



5

6

7

8



9

10
